Total Complexity | 7 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 64.71% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | abstract class AbstractCollectionComparator implements CollectionComparatorInterface |
||
8 | { |
||
9 | 33 | public function notIn(array $array, array $values): array |
|
10 | { |
||
11 | 33 | return array_values( |
|
12 | 33 | array_udiff($array, $values, $this->getComparisonFunction()) |
|
13 | ); |
||
14 | } |
||
15 | |||
16 | 21 | public function difference(array $array1, array $array2): array |
|
17 | { |
||
18 | return [ |
||
19 | 21 | ...$this->notIn($array1, $array2), |
|
20 | 21 | ...$this->notIn($array2, $array1) |
|
21 | ]; |
||
22 | } |
||
23 | |||
24 | 15 | public function intersection($array, $values): array |
|
25 | { |
||
26 | 15 | return array_values( |
|
27 | 15 | array_uintersect($array, $values, $this->getComparisonFunction()) |
|
28 | ); |
||
29 | } |
||
30 | |||
31 | 6 | public function matches(array $array1, array $array2): bool |
|
32 | { |
||
33 | 6 | return empty($this->difference($array1, $array2)); |
|
34 | } |
||
35 | |||
36 | protected function stripDuplicates(array $array): array |
||
37 | { |
||
38 | return array_unique($array, SORT_REGULAR); |
||
39 | } |
||
40 | |||
41 | protected function whatEvenIsThis(array $a, array $b): array |
||
52 | } |
||
53 | } |
||
54 |