| Conditions | 7 |
| Paths | 7 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 7.0957 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 5 | public function match(array $item, array $arguments, array $filterProcessors): bool |
|
| 17 | { |
||
| 18 | 5 | if (count($arguments) !== 1) { |
|
| 19 | 1 | throw new \RuntimeException('$arguments should contain exactly one element!'); |
|
| 20 | 4 | } elseif (!is_array($arguments[0])) { |
|
| 21 | 1 | throw new \RuntimeException('$arguments[0] is not an array!'); |
|
| 22 | 3 | } elseif (count($arguments[0]) < 1) { |
|
| 23 | 1 | throw new \RuntimeException('At least operator should be provided!'); |
|
| 24 | } |
||
| 25 | 2 | $operator = array_shift($arguments[0]); |
|
| 26 | 2 | if (!is_string($operator)) { |
|
| 27 | throw new \RuntimeException('Operator is not a string!'); |
||
| 28 | 2 | } elseif (strlen($operator) === 0) { |
|
| 29 | 1 | throw new \RuntimeException('The operator string cannot be empty!'); |
|
| 30 | } |
||
| 31 | |||
| 32 | 1 | $processor = $filterProcessors[$operator] ?? null; |
|
| 33 | 1 | if ($processor === null) { |
|
| 34 | throw new \RuntimeException(sprintf('"%s" operator is not supported!', $operator)); |
||
| 35 | } |
||
| 36 | /* @var $processor IterableProcessorInterface */ |
||
| 37 | 1 | return !$processor->match($item, $arguments[0], $filterProcessors); |
|
| 38 | } |
||
| 41 |