Total Complexity | 4 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
8 | class ContainsNoDuplicateItem extends Constraint |
||
9 | { |
||
10 | 9 | protected function matches($other): bool |
|
14 | } |
||
15 | |||
16 | /** |
||
17 | * @return (mixed|null)[] |
||
18 | * |
||
19 | * @psalm-return non-empty-list<mixed|null> |
||
20 | */ |
||
21 | 9 | private function deduplicate(array $array): array |
|
22 | { |
||
23 | 9 | $unique = []; |
|
24 | do { |
||
25 | 9 | $element = \array_shift($array); |
|
26 | 9 | $unique[] = $element; |
|
27 | |||
28 | 9 | $array = \array_udiff( |
|
29 | 9 | $array, |
|
30 | 9 | [$element], |
|
31 | 9 | function($first, $second) { |
|
32 | 9 | return $first <=> $second; |
|
33 | 9 | } |
|
34 | ); |
||
35 | 9 | } while (\count($array) > 0); |
|
36 | |||
37 | 9 | return $unique; |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * @return string |
||
42 | */ |
||
43 | 1 | public function toString(): string |
|
46 | } |
||
47 | } |
||
48 |