Passed
Push — master ( 5f88dd...10f6bc )
by Smoren
12:50
created

ArrayHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3

1 Method

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