Arr::dot()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 9
nc 4
nop 2
dl 0
loc 18
rs 9.2
c 0
b 0
f 0
ccs 11
cts 11
cp 1
crap 4
1
<?php namespace Arcanesoft\Settings\Helpers;
2
3
use Illuminate\Support\Arr as IlluminateArr;
4
5
/**
6
 * Class     Arr
7
 *
8
 * @package  Arcanesoft\Settings\Helpers
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class Arr extends IlluminateArr
12
{
13
    /**
14
     * Flatten a multi-dimensional associative array with dots.
15
     *
16
     * @param  array   $array
17
     * @param  string  $prepend
18
     *
19
     * @return array
20
     */
21 18
    public static function dot($array, $prepend = '')
22
    {
23 18
        $results = [];
24
25 18
        foreach ($array as $key => $value) {
26 18
            if (is_array($value)) {
27 6
                if (self::isAssoc($value)) {
28 3
                    $results = array_merge($results, self::dot($value, $prepend.$key.'.'));
29
30 3
                    continue;
31
                }
32 2
            }
33
34 18
            $results[$prepend.$key] = $value;
35 12
        }
36
37 18
        return $results;
38
    }
39
}
40