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