Conditions | 6 |
Paths | 5 |
Total Lines | 14 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 6 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | 12 | public function filter( |
|
23 | iterable $data, |
||
24 | string $prefix, |
||
25 | bool $lowercase = true, |
||
26 | bool $trim = true): array |
||
27 | { |
||
28 | 12 | $filtered = []; |
|
29 | 12 | foreach ($data as $index => $value) { |
|
30 | 12 | if ($trim && '' !== $prefix && str_starts_with($index, $prefix)) { |
|
31 | 6 | $index = str_replace($prefix, '', $index); |
|
32 | } |
||
33 | 12 | $filtered[$lowercase ? strtolower($index) : $index] = $value; |
|
34 | } |
||
35 | 12 | return $filtered; |
|
36 | } |
||
62 |