Skip to content

Commit

Permalink
Resolve a code sniffer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamara committed Dec 30, 2024
1 parent b513a8d commit f449618
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/Service/ExpressCheckoutService.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ public function createCart(
$cart = $this->cartService->recalculate($cart, $updatedSalesChannelContext);

$paymentMethods = $this->paymentMethodsService->getPaymentMethods($updatedSalesChannelContext);
$filteredPaymentMethods = $this->paymentMethodsFilterService->filterAndValidatePaymentMethods($paymentMethods, $cart, $salesChannelContext);
$filteredPaymentMethods = $this->paymentMethodsFilterService
->filterAndValidatePaymentMethods($paymentMethods, $cart, $salesChannelContext);

return [
'cart' => $cart,
Expand Down
22 changes: 12 additions & 10 deletions src/Service/PaymentMethodsFilterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,22 +324,25 @@ public function filterAndValidatePaymentMethods(
];

// Filter methods by type and configuration
$filteredMethods = array_filter($paymentMethods, function ($method) use ($allowedMethods, $salesChannelContext) {
$type = $method['type'];
if (!isset($allowedMethods[$type])) {
return false;
}
$filteredMethods =
array_filter($paymentMethods, function ($method) use ($allowedMethods, $salesChannelContext) {
$type = $method['type'];
if (!isset($allowedMethods[$type])) {
return false;
}

$configCheck = $allowedMethods[$type];
return $configCheck($salesChannelContext->getSalesChannelId());
});
$configCheck = $allowedMethods[$type];
return $configCheck($salesChannelContext->getSalesChannelId());
});

// Check rules for every method
$validMethods = [];
foreach ($filteredMethods as $method) {
$availabilityRule = $method['availabilityRule'] ?? null;

if (!$availabilityRule || $availabilityRule->getPayload()->match(new CartRuleScope($cart, $salesChannelContext))) {
if (!$availabilityRule ||
$availabilityRule->getPayload()->match(new CartRuleScope($cart, $salesChannelContext))
) {
$validMethods[] = $method;
}
}
Expand All @@ -348,5 +351,4 @@ public function filterAndValidatePaymentMethods(

return $paymentMethodsResponse;
}

}

0 comments on commit f449618

Please sign in to comment.