| Conditions | 7 |
| Paths | 6 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | public function isEligible(PromotionSubjectInterface $subject, array $configuration): bool |
||
| 18 | { |
||
| 19 | if (!$subject instanceof OrderInterface) { |
||
| 20 | throw new UnsupportedTypeException($subject, OrderInterface::class); |
||
| 21 | } |
||
| 22 | /** @var OrderItemInterface $item */ |
||
| 23 | foreach ($subject->getItems() as $item) { |
||
| 24 | if (!($configuration['product'] instanceof ProductInterface)) { |
||
| 25 | throw new UnsupportedTypeException($configuration['product'], ProductInterface::class); |
||
| 26 | } |
||
| 27 | $product = $item->getProduct(); |
||
| 28 | if ($product instanceof ProductInterface) { |
||
| 29 | if ($configuration['product']->getCode() === $product->getCode() |
||
| 30 | && $configuration['quantity'] <= $item->getQuantity()) { |
||
| 31 | return true; |
||
| 32 | } |
||
| 33 | } |
||
| 34 | } |
||
| 35 | return false; |
||
| 36 | } |
||
| 38 |