Conditions | 4 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
56 | protected function get(array $dataset, $length) |
||
57 | { |
||
58 | $originalLength = count($dataset); |
||
59 | $remainingLength = $originalLength - $length + 1; |
||
60 | for ($i = 0; $i < $remainingLength; $i++) { |
||
61 | $current = $dataset[$i]; |
||
62 | if ($length === 1) { |
||
63 | yield [$current]; |
||
64 | } else { |
||
65 | $remaining = array_slice($dataset, $i + 1); |
||
66 | foreach ($this->get($remaining, $length - 1) as $permutation) { |
||
67 | array_unshift($permutation, $current); |
||
68 | yield $permutation; |
||
69 | } |
||
70 | } |
||
71 | } |
||
72 | } |
||
73 | } |
||
74 |