Conditions | 5 |
Paths | 5 |
Total Lines | 14 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 5.675 |
Changes | 0 |
1 | <?php |
||
33 | 2 | public static function removeEmptyElementsRecursively(array $array): array |
|
34 | { |
||
35 | 2 | $result = $array; |
|
36 | 2 | foreach ($result as $key => $value) { |
|
37 | 2 | if (is_array($value)) { |
|
38 | $result[$key] = self::removeEmptyElementsRecursively($value); |
||
39 | if ($result[$key] === []) { |
||
40 | unset($result[$key]); |
||
41 | } |
||
42 | 2 | } elseif ($value === null) { |
|
43 | 2 | unset($result[$key]); |
|
44 | } |
||
45 | } |
||
46 | 2 | return $result; |
|
47 | } |
||
49 |