Arr::arrayMergeRecursiveDistinct()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 7
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 5
rs 9.6111
1
<?php
2
3
namespace ThinKit\Helpers;
4
5
class Arr
6
{
7 1
    public static function arrayMergeRecursiveDistinct(array &$array1, array &$array2): array
8
    {
9 1
        $merged = $array1;
10 1
        foreach ($array2 as $key => &$value) {
11 1
            if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
12 1
                $merged[$key] = static::arrayMergeRecursiveDistinct($merged[$key], $value);
13
            } else {
14 1
                $merged[$key] = $value;
15
            }
16
        }
17
18 1
        return $merged;
19
    }
20
}
21