Total Complexity | 4 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
13 | final class In implements FilterInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var bool[]|float[]|int[]|string[] Values to check against. |
||
17 | */ |
||
18 | private array $values; |
||
19 | |||
20 | /** |
||
21 | * @param string $field Name of the field to compare. |
||
22 | * @param bool[]|float[]|int[]|string[] $values Values to check against. |
||
23 | */ |
||
24 | 6 | public function __construct( |
|
25 | public readonly string $field, |
||
26 | array $values |
||
27 | ) { |
||
28 | 6 | foreach ($values as $value) { |
|
29 | /** @psalm-suppress DocblockTypeContradiction */ |
||
30 | 6 | if (!is_scalar($value)) { |
|
31 | 1 | throw new InvalidArgumentException( |
|
32 | 1 | sprintf( |
|
33 | 1 | 'The value should be scalar. "%s" is received.', |
|
34 | 1 | get_debug_type($value), |
|
35 | 1 | ) |
|
36 | 1 | ); |
|
37 | } |
||
38 | } |
||
39 | 5 | $this->values = $values; |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * @return bool[]|float[]|int[]|string[] |
||
44 | */ |
||
45 | 5 | public function getValues(): array |
|
48 | } |
||
49 | } |
||
50 |