Total Complexity | 9 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class Configuration extends AbstractCommand |
||
11 | { |
||
12 | public int $page; |
||
13 | |||
14 | public int $limit; |
||
15 | |||
16 | public array $filter = []; |
||
17 | |||
18 | public array $order = []; |
||
19 | |||
20 | /** @psalm-suppress MixedArrayAssignment */ |
||
21 | 76 | public function setFilter(array $conditions): self |
|
22 | { |
||
23 | /** |
||
24 | * @var string $exp |
||
25 | * @var array $values |
||
26 | */ |
||
27 | 76 | foreach ($conditions as $exp => $values) { |
|
28 | 76 | Assert::oneOf($exp, Builder::SUPPORTED_EXPRESSIONS); |
|
29 | /** |
||
30 | * @var string $propertyAlias |
||
31 | * @var mixed $value |
||
32 | */ |
||
33 | 75 | foreach ($values as $propertyAlias => $value) { |
|
34 | 75 | if (!\array_key_exists($exp, $this->filter)) { |
|
35 | 75 | $this->filter[$exp] = []; |
|
36 | } |
||
37 | |||
38 | 75 | if (\is_string($value) && preg_match('#\|#', $value)) { |
|
39 | 30 | $value = JsonNormalizer::normalize(explode('|', $value)); |
|
40 | } |
||
41 | |||
42 | 75 | $this->filter[$exp][$propertyAlias] = \is_array($value) ? $value : [$value]; |
|
43 | } |
||
44 | } |
||
45 | |||
46 | 75 | return $this; |
|
47 | } |
||
48 | |||
49 | 2 | public function setOrder(array $conditions): self |
|
61 | } |
||
62 | } |
||
63 |