| Conditions | 8 |
| Paths | 8 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 8 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | 24 | public function match(array $item, array $arguments, array $filterProcessors): bool |
|
| 23 | { |
||
| 24 | 24 | if (count($arguments) !== 3) { |
|
| 25 | 4 | throw new InvalidArgumentException('$arguments should contain exactly three elements.'); |
|
| 26 | } |
||
| 27 | |||
| 28 | /** @var string $field */ |
||
| 29 | 20 | [$field, $firstValue, $secondValue] = $arguments; |
|
| 30 | 20 | FilterDataValidationHelper::assertFieldIsString($field); |
|
| 31 | |||
| 32 | 12 | if (!array_key_exists($field, $item)) { |
|
| 33 | 2 | return false; |
|
| 34 | } |
||
| 35 | |||
| 36 | 10 | if (!$item[$field] instanceof DateTimeInterface) { |
|
| 37 | 5 | return $item[$field] >= $firstValue && $item[$field] <= $secondValue; |
|
| 38 | } |
||
| 39 | |||
| 40 | 5 | return $firstValue instanceof DateTimeInterface |
|
| 41 | && $secondValue instanceof DateTimeInterface |
||
| 42 | 5 | && $item[$field]->getTimestamp() >= $firstValue->getTimestamp() |
|
| 43 | 5 | && $item[$field]->getTimestamp() <= $secondValue->getTimestamp(); |
|
| 44 | } |
||
| 46 |