Total Complexity | 9 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | trait ListOperationsTrait |
||
10 | { |
||
11 | |||
12 | |||
13 | |||
14 | 2 | public function plus(iterable $other): ListInterface |
|
15 | { |
||
16 | 2 | $list = listOf(...$this->array); |
|
17 | 2 | $list->addAll($other); |
|
18 | 2 | return $list; |
|
19 | } |
||
20 | |||
21 | /** |
||
22 | * @inheritDoc |
||
23 | */ |
||
24 | 4 | public function minus(iterable $values): ListInterface |
|
25 | { |
||
26 | 4 | $valuesList = emptyList(); |
|
27 | 4 | if (!$values instanceof ListInterface && is_array($values)) { |
|
28 | 1 | $valuesList->setArray($values); |
|
29 | } else { |
||
30 | 3 | $valuesList = $values; |
|
31 | } |
||
32 | 4 | $newInstance = emptyList(); |
|
33 | 4 | foreach ($this->array as $value) { |
|
34 | 4 | if (!$valuesList->contains($value)) { |
|
35 | 4 | $newInstance->add($value); |
|
36 | } |
||
37 | } |
||
38 | 4 | return $newInstance; |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * @inheritDoc |
||
43 | */ |
||
44 | 2 | public function intersect(ListInterface $list): ListInterface |
|
53 | } |
||
54 | } |