ArrayUtils   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 24
ccs 9
cts 9
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A flatArrayRecursive() 0 17 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiechu\SymfonyCommonsBundle\Utils;
6
7
class ArrayUtils
8
{
9
    /**
10
     * @param null|array $array
11
     *
12
     * @return array
13
     */
14 19
    public static function flatArrayRecursive(?array $array): array
15
    {
16 19
        if (empty($array)) {
17 1
            return [];
18
        }
19
20 19
        $resultArray = [];
21
22 19
        foreach ($array as $key => $value) {
23 19
            if (\is_array($value)) {
24 19
                $resultArray = array_merge($resultArray, static::flatArrayRecursive($value));
25
            } else {
26 19
                $resultArray[] = $value;
27
            }
28
        }
29
30 19
        return $resultArray;
31
    }
32
}
33