Passed
Branch master (df2ee3)
by Dawid
07:19 queued 02:10
created

ArrayUtils   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 21
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

1 Method

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