| Conditions | 4 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 39 | protected function get(array $dataset, $length): Generator |
||
| 40 | { |
||
| 41 | $originalLength = count($dataset); |
||
| 42 | $remainingLength = $originalLength - $length + 1; |
||
| 43 | |||
| 44 | for ($i = 0; $i < $remainingLength; ++$i) { |
||
| 45 | $current = $dataset[$i]; |
||
| 46 | |||
| 47 | if (1 === $length) { |
||
| 48 | yield [$current]; |
||
| 49 | } else { |
||
| 50 | $remaining = array_slice($dataset, $i + 1); |
||
| 51 | |||
| 52 | foreach ($this->get($remaining, $length - 1) as $permutation) { |
||
| 53 | array_unshift($permutation, $current); |
||
| 54 | |||
| 55 | yield $permutation; |
||
| 56 | } |
||
| 61 |