Arr   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A mergeRecursive() 0 13 5
1
<?php
2
3
/*
4
 * This file is part of the PHINT package.
5
 *
6
 * (c) Jitendra Adhikari <[email protected]>
7
 *     <https://github.com/adhocore>
8
 *
9
 * Licensed under MIT license.
10
 */
11
12
namespace Ahc\Phint\Util;
13
14
class Arr
15
{
16
    /**
17
     * @see http://php.net/array_merge_recursive#92195
18
     *
19
     * @param array $array1
20
     * @param array $array2
21
     *
22
     * @return array
23
     */
24
    public static function mergeRecursive(array $array1, array $array2)
25
    {
26
        $merged = $array1;
27
28
        foreach ($array2 as $key => &$value) {
29
            if (\is_array($value) && isset($merged[$key]) && \is_array($merged[$key])) {
30
                $merged[$key] = self::mergeRecursive($merged[$key], $value);
31
            } else {
32
                $merged[$key] = $value;
33
            }
34
        }
35
36
        return $merged;
37
    }
38
}
39