Passed
Push — master ( 2f6942...d6d802 )
by Chris
28:11
created

AltDiff   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
dl 0
loc 17
ccs 0
cts 8
cp 0
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A remix() 0 12 3
1
<?php
2
3
namespace WebTheory\Collection\Fusion;
4
5
use WebTheory\Collection\Contracts\ArrayFusionInterface;
6
use WebTheory\Collection\Fusion\Abstracts\AbstractArrayFusion;
7
8
class AltDiff extends AbstractArrayFusion implements ArrayFusionInterface
9
{
10
    /**
11
     * Creates a diff starting with the first non-empty array
12
     */
13
    public function remix(array ...$collections): array
14
    {
15
        $fusion = array_shift($collections);
16
        $callback = $this->getComparisonCallback();
17
18
        foreach ($collections as $collection) {
19
            $fusion = !empty($fusion)
20
                ? array_udiff($fusion, $collection, $callback)
21
                : array_udiff($collection, $fusion, $callback);
22
        }
23
24
        return $fusion;
25
    }
26
}
27