Conditions | 4 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
39 | 1 | private function getPermutations(array $dataset): Generator |
|
40 | { |
||
41 | 1 | foreach ($dataset as $key => $firstItem) { |
|
42 | 1 | $remaining = $dataset; |
|
43 | |||
44 | 1 | array_splice($remaining, $key, 1); |
|
45 | |||
46 | 1 | if (0 === count($remaining)) { |
|
47 | 1 | yield [$firstItem]; |
|
48 | |||
49 | 1 | continue; |
|
50 | } |
||
51 | |||
52 | 1 | foreach ($this->getPermutations($remaining) as $Permutate) { |
|
53 | 1 | array_unshift($Permutate, $firstItem); |
|
54 | |||
55 | 1 | yield $Permutate; |
|
56 | } |
||
60 |