| Conditions | 5 |
| Paths | 5 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 5.1502 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | 16 | protected function validate(ItemInterface $item, PurchaseContext $context) |
|
| 16 | { |
||
| 17 | 16 | if (!$item->isProduct()) { |
|
| 18 | return; |
||
| 19 | } |
||
| 20 | 16 | if ($item->getProductClass()->getStockUnlimited()) { |
|
| 21 | 13 | return; |
|
| 22 | } |
||
| 23 | 3 | $stock = $item->getProductClass()->getStock(); |
|
| 24 | 3 | $quantity = $item->getQuantity(); |
|
| 25 | 3 | if ($stock == 0) { |
|
| 26 | throw ItemValidateException::fromProductClass('cart.zero.stock', $item->getProductClass()); |
||
| 27 | } |
||
| 28 | 3 | if ($stock < $quantity) { |
|
| 29 | 1 | throw ItemValidateException::fromProductClass('cart.over.stock', $item->getProductClass()); |
|
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 39 |