BitBagCommerce /
SyliusMolliePlugin
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file has been created by developers from BitBag. |
||
| 5 | * Feel free to contact us once you face any issues or want to start |
||
| 6 | * You can find more information about us on https://bitbag.io and write us |
||
| 7 | * an email on [email protected]. |
||
| 8 | */ |
||
| 9 | |||
| 10 | declare(strict_types=1); |
||
| 11 | |||
| 12 | namespace BitBag\SyliusMolliePlugin\Resolver; |
||
| 13 | |||
| 14 | use BitBag\SyliusMolliePlugin\Entity\MollieGatewayConfigInterface; |
||
| 15 | use BitBag\SyliusMolliePlugin\Payments\Methods\MealVoucher; |
||
| 16 | use Sylius\Component\Core\Model\OrderItemInterface; |
||
| 17 | |||
| 18 | final class MealVoucherResolver implements MealVoucherResolverInterface |
||
| 19 | { |
||
| 20 | public function resolve(MollieGatewayConfigInterface $method, OrderItemInterface $item): ?string |
||
| 21 | { |
||
| 22 | if ($method->getMethodId() === MealVoucher::MEAL_VOUCHERS) { |
||
| 23 | return $this->getMealVoucherCategory($method, $item); |
||
| 24 | } |
||
| 25 | |||
| 26 | return null; |
||
| 27 | } |
||
| 28 | |||
| 29 | private function getMealVoucherCategory(MollieGatewayConfigInterface $method, OrderItemInterface $item): ?string |
||
| 30 | { |
||
| 31 | if (null !== $this->getMealVoucherFromItem($item)) { |
||
| 32 | return $this->getMealVoucherFromItem($item); |
||
| 33 | } |
||
| 34 | if (null !== $method->getDefaultCategory()) { |
||
| 35 | return $method->getDefaultCategory()->getName(); |
||
| 36 | } |
||
| 37 | |||
| 38 | throw new \LogicException(\sprintf('Voucher need default category, product category found in product name %s', $item->getProduct()->getName())); |
||
| 39 | } |
||
| 40 | |||
| 41 | private function getMealVoucherFromItem(OrderItemInterface $item): ?string |
||
| 42 | { |
||
| 43 | $product = $item->getProduct(); |
||
| 44 | |||
| 45 | return null === $product->getProductType() ? null : $product->getProductType()->getName(); |
||
|
0 ignored issues
–
show
|
|||
| 46 | } |
||
| 47 | } |
||
| 48 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.