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