Conditions | 5 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
28 | public static function applyFilter(array $input, array $filter = []): array { |
||
29 | 1 | if(count($filter) === 0) { |
|
30 | 1 | return $input; |
|
31 | } |
||
32 | 1 | return array_values(array_filter($input, function($item) use($filter) { |
|
33 | /** @var string $key */ |
||
34 | 1 | foreach($filter as $key => $value) { |
|
35 | 1 | $operator = static::getOperator($key); |
|
36 | 1 | $key = Strings::endsWith($key, $operator) ? Strings::before($key, $operator) : $key; |
|
37 | 1 | if(!eval("return \"{$item->$key}\" $operator \"$value\";")) { |
|
38 | 1 | return false; |
|
39 | } |
||
40 | } |
||
41 | 1 | return true; |
|
42 | 1 | })); |
|
45 | ?> |