Arr::flatten()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 10
cc 3
nc 3
nop 2
crap 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