| Conditions | 5 |
| Paths | 5 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 10 | public function match(object|array $item, FilterInterface $filter, array $iterableFilterHandlers): bool |
|
| 26 | { |
||
| 27 | 10 | if (!$filter instanceof All) { |
|
| 28 | 1 | throw new InvalidArgumentException('Incorrect filter.'); |
|
| 29 | } |
||
| 30 | |||
| 31 | 9 | foreach ($filter->getFilters() as $subFilter) { |
|
| 32 | 9 | $filterHandler = $iterableFilterHandlers[$subFilter::class] ?? null; |
|
| 33 | 9 | if ($filterHandler === null) { |
|
| 34 | 1 | throw new LogicException(sprintf('Filter "%s" is not supported.', $subFilter::class)); |
|
| 35 | } |
||
| 36 | 8 | if (!$filterHandler->match($item, $subFilter, $iterableFilterHandlers)) { |
|
| 37 | 6 | return false; |
|
| 38 | } |
||
| 39 | } |
||
| 40 | |||
| 41 | 4 | return true; |
|
| 42 | } |
||
| 44 |