ArrayDiff::getDiff()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 13
rs 10
c 0
b 0
f 0
cc 3
nc 4
nop 1
1
<?php
2
3
namespace DrLenux\ArraySmartDiff;
4
5
/**
6
 * Class ArrayDiff
7
 * @package DrLenux\ArraySmartDiff
8
 */
9
class ArrayDiff
10
{
11
    /**
12
     * @param array ...$array
13
     * @return array
14
     */
15
    public static function getDiff(array ...$array)
16
    {
17
        $old = array_diff_assoc(...$array);
18
        $new = array_diff_assoc(...(array_reverse($array)));
19
20
        $res = [];
21
        foreach ($new as $v => $k) {
22
            $res[$v]['new'] = $k;
23
        }
24
        foreach ($old as $v => $k) {
25
            $res[$v]['old'] = $k;
26
        }
27
        return $res;
28
    }
29
}