Completed
Push — master ( 52ead2...fd316a )
by David
12s queued 10s
created

Utils::arrayFilterRec()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace TheAentMachine\AentDockerCompose\Service;
4
5
class Utils
6
{
7
    /**
8
     * Delete all key/value pairs with empty value by recursively using array_filter
9
     * @param array $input
10
     * @return mixed[] array
11
     */
12
    public static function arrayFilterRec(array $input): array
13
    {
14
        foreach ($input as &$value) {
15
            if (\is_array($value)) {
16
                $value = self::arrayFilterRec($value);
17
            }
18
        }
19
        return array_filter($input);
20
    }
21
}
22