Conditions | 7 |
Paths | 14 |
Total Lines | 26 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 7 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
19 | 197 | public static function partialIntersection(bool $strict, int $m, iterable ...$sets): \Generator |
|
20 | { |
||
21 | 197 | $iterator = new \MultipleIterator(\MultipleIterator::MIT_NEED_ANY); |
|
22 | |||
23 | 197 | foreach ($sets as $set) { |
|
24 | 189 | $iterator->attachIterator(IteratorFactory::makeIterator($set)); |
|
25 | } |
||
26 | |||
27 | 197 | $usageMap = []; |
|
28 | |||
29 | 197 | foreach ($iterator as $values) { |
|
30 | 169 | foreach ($values as $value) { |
|
31 | 169 | if ($value === null) { |
|
32 | 65 | continue; |
|
33 | } |
||
34 | |||
35 | 169 | $hash = UniqueExtractor::getString($value, $strict); |
|
36 | |||
37 | 169 | if (!isset($usageMap[$hash])) { |
|
38 | 169 | $usageMap[$hash] = 0; |
|
39 | } |
||
40 | |||
41 | 169 | $usageMap[$hash]++; |
|
42 | |||
43 | 169 | if ($usageMap[$hash] === $m) { |
|
44 | 108 | yield $value; |
|
45 | } |
||
50 |