Arr   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A flatten() 0 11 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Efabrica\Translatte\Helper;
6
7
class Arr
8
{
9 30
    public static function flatten(array $array, string $prefix = ''): array
10
    {
11 30
        $result = array();
12 30
        foreach ($array as $key => $value) {
13 27
            if (is_array($value)) {
14 24
                $result = $result + self::flatten($value, $prefix . $key . '.');
15
            } else {
16 27
                $result[$prefix . $key] = $value;
17
            }
18
        }
19 30
        return $result;
20
    }
21
}
22