Passed
Push — master ( eb3d86...848e05 )
by Smoren
02:38
created

ArrayHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A flatten() 0 12 3
1
<?php
2
3
namespace Smoren\Schemator\Util;
4
5
/**
6
 * @internal
7
 */
8
class ArrayHelper
9
{
10
    /**
11
     * Flattens an array
12
     * @param array $arr array to flatten
13
     * @return array flat array
14
     */
15
    public static function flatten(array $arr): array
16
    {
17
        $tmp = [];
18
        foreach($arr as $val) {
19
            if(is_array($val)) {
20
                $tmp = array_merge($tmp, static::flatten($val));
21
            } else {
22
                $tmp[] = $val;
23
            }
24
        }
25
26
        return $tmp;
27
    }
28
}
29