Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
51 | 142 | private static function generateFixedLengthPermutations(array $items, array $perms = []): \Generator |
|
52 | { |
||
53 | 142 | if (empty($items)) { |
|
54 | 142 | yield $perms; |
|
55 | } else { |
||
56 | 142 | for ($i = count($items)-1; $i>=0; $i--) { |
|
57 | 142 | $newitems = $items; |
|
58 | 142 | $newperms = $perms; |
|
59 | 142 | list($foo) = array_splice($newitems, $i, 1); |
|
60 | 142 | array_unshift($newperms, $foo); |
|
61 | 142 | yield from self::generateFixedLengthPermutations($newitems, $newperms); |
|
62 | } |
||
63 | } |
||
64 | 142 | } |
|
65 | } |
||
66 |