Total Complexity | 4 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
15 | abstract class Compare implements FilterInterface |
||
16 | { |
||
17 | private bool|DateTimeInterface|float|int|string $value; |
||
18 | |||
19 | /** |
||
20 | * @param string $field Name of the field to compare. |
||
21 | * @param bool|DateTimeInterface|float|int|string $value Value to compare to. |
||
22 | */ |
||
23 | 116 | public function __construct(private string $field, mixed $value) |
|
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param bool|DateTimeInterface|float|int|string $value Value to compare to. |
||
30 | */ |
||
31 | 2 | final public function withValue(mixed $value): static |
|
32 | { |
||
33 | 2 | $new = clone $this; |
|
34 | 2 | $new->setValue($value); |
|
35 | 2 | return $new; |
|
36 | } |
||
37 | |||
38 | 90 | public function toCriteriaArray(): array |
|
39 | { |
||
40 | 90 | return [static::getOperator(), $this->field, $this->value]; |
|
41 | } |
||
42 | |||
43 | 116 | private function setValue(mixed $value): void |
|
47 | } |
||
48 | } |
||
49 |