Conditions | 5 |
Paths | 7 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public static function flatten(array $array, string $prefix = '') : array |
||
20 | { |
||
21 | $result = []; |
||
22 | foreach ($array as $key => $value) { |
||
23 | if ($prefix) { |
||
24 | $key = $prefix . '.' . $key; |
||
25 | } |
||
26 | if (is_array($value)) { |
||
27 | $result = array_merge($result, self::flatten($value, (string)$key)); |
||
28 | } else { |
||
29 | $result[$key] = is_scalar($value) ? $value : gettype($value); |
||
30 | } |
||
31 | } |
||
32 | return $result; |
||
33 | } |
||
34 | } |