Conditions | 4 |
Paths | 6 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
51 | 2 | private function randomize(iterable $iterable, int $seed): Generator |
|
52 | { |
||
53 | 2 | $queue = []; |
|
54 | |||
55 | 2 | foreach (new UnpackIterableAggregate($iterable) as $key => $value) { |
|
56 | 2 | if (0 === mt_rand(0, $seed)) { |
|
57 | 2 | yield $key => $value; |
|
58 | |||
59 | 2 | continue; |
|
60 | } |
||
61 | |||
62 | 1 | $queue[] = [$key, $value]; |
|
63 | } |
||
64 | |||
65 | 2 | if ([] !== $queue) { |
|
66 | 1 | yield from $this->randomize($queue, $seed); |
|
67 | } |
||
70 |