Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
80 | protected function generate(array $elements, $length) { |
||
81 | if (count($elements) <= 1) { |
||
82 | yield $elements; |
||
83 | } else { |
||
84 | foreach ($this->generate(array_slice($elements, 1)) as $permutation) { |
||
85 | foreach (range(0, count($elements) - 1) as $i) { |
||
86 | yield array_merge( |
||
87 | array_slice($permutation, 0, $i), |
||
88 | [$elements[0]], |
||
89 | array_slice($permutation, $i) |
||
90 | ); |
||
91 | } |
||
92 | } |
||
93 | } |
||
94 | } |
||
95 | |||
110 |