| Conditions | 4 |
| Paths | 2 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public function resolve(ProductInterface $product, ProductOptionInterface $productOption): Collection |
||
| 27 | { |
||
| 28 | if (!$product->hasOption($productOption)) { |
||
| 29 | throw new \InvalidArgumentException( |
||
| 30 | sprintf( |
||
| 31 | 'Cannot resolve available product option values. Option "%s" does not belong to product "%s".', |
||
| 32 | $product->getCode(), |
||
| 33 | $productOption->getCode() |
||
| 34 | ) |
||
| 35 | ); |
||
| 36 | } |
||
| 37 | |||
| 38 | return $productOption->getValues()->filter( |
||
| 39 | static function (ProductOptionValueInterface $productOptionValue) use ($product) { |
||
| 40 | foreach ($product->getEnabledVariants() as $productVariant) { |
||
| 41 | if ($productVariant->hasOptionValue($productOptionValue)) { |
||
| 42 | return true; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | return false; |
||
| 47 | } |
||
| 48 | ); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |