Completed
Push — master ( 877236...2dc251 )
by ARCANEDEV
05:46
created

Arr::dot()   A

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 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 18
ccs 11
cts 11
cp 1
rs 9.2
cc 4
eloc 9
nc 4
nop 2
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 24
    public static function dot($array, $prepend = '')
22
    {
23 24
        $results = [];
24
25 24
        foreach ($array as $key => $value) {
26 24
            if (is_array($value)) {
27 8
                if (self::isAssoc($value)) {
28 4
                    $results = array_merge($results, self::dot($value, $prepend.$key.'.'));
29
30 4
                    continue;
31
                }
32 3
            }
33
34 24
            $results[$prepend.$key] = $value;
35 18
        }
36
37 24
        return $results;
38
    }
39
}
40