Completed
Push — master ( b96c3f...17a0ce )
by Florian
15s queued 11s
created

src/Link/Diff.php (1 issue)

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(
1 ignored issue
show
Bug Best Practice introduced by
The property array does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
28 2
            $this->array,
29 2
            $array2 instanceof Chain ? $array2->array : $array2
30
        );
31
32 2
        return $this;
33
    }
34
}
35