Conditions | 7 |
Paths | 10 |
Total Lines | 26 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 7 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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 | } |
||
63 |