ArrayDiff   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B arrayDiffRecursive() 0 22 7
1
<?php
2
3
namespace Locastic\Loggastic\Util;
4
5
final class ArrayDiff
6
{
7
    public static function arrayDiffRecursive($array1, $array2): array
8
    {
9
        $return = [];
10
11
        foreach ($array1 as $key => $value) {
12
            if (is_array($array2) && array_key_exists($key, $array2)) {
13
                if (is_array($value)) {
14
                    $recursiveDiff = self::arrayDiffRecursive($value, $array2[$key]);
15
                    if (count($recursiveDiff)) {
16
                        $return[$key] = $recursiveDiff;
17
                    }
18
                } else {
19
                    if ($value != $array2[$key]) {
20
                        $return[$key] = $value;
21
                    }
22
                }
23
            } else {
24
                $return[$key] = $value;
25
            }
26
        }
27
28
        return $return;
29
    }
30
}
31