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

AltDiff::remix()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 12
ccs 0
cts 8
cp 0
rs 10
c 1
b 0
f 0
cc 3
nc 3
nop 1
crap 12
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