Diff   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 20
ccs 5
cts 5
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A diff() 0 8 2
1
<?php
2
3
namespace Cocur\Chain\Link;
4
5
use Cocur\Chain\Chain;
6
7
/**
8
 * Diff.
9
 *
10
 * @author    Florian Eckerstorfer
11
 * @copyright 2015-2018 Florian Eckerstorfer
12
 */
13
trait Diff
14
{
15
    /**
16
     * Computes the difference of arrays.
17
     *
18
     * Compares the array to another array or instance of `Cocur\Chain\Chain` and will set the array of elements that
19
     * are not present in the other array.
20
     *
21
     * @param Chain|array $array2 an array or instance of `Cocur\Chain\Chain` to compare against
22
     *
23
     * @return self
24
     */
25 2
    public function diff($array2): self
26
    {
27 2
        $this->array = array_diff(
28 2
            $this->array,
29 2
            $array2 instanceof Chain ? $array2->array : $array2
30
        );
31
32 2
        return $this;
33
    }
34
}
35