Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | 6 | public function getAllCombinations(array $arguments, array $currentCombination = []): array |
|
10 | { |
||
11 | 6 | $combinations = []; |
|
12 | 6 | $argumentsTail = $arguments; |
|
13 | 6 | $key = key($argumentsTail); |
|
14 | 6 | unset($argumentsTail[$key]); |
|
15 | |||
16 | 6 | if (0 === count($arguments)) { |
|
17 | 6 | return [$currentCombination]; |
|
18 | } |
||
19 | |||
20 | 6 | foreach (current($arguments) as $element) { |
|
21 | 6 | $newCombination = $currentCombination; |
|
22 | 6 | array_push($newCombination, $element); |
|
23 | 6 | $combinations = $this->extend( |
|
24 | 6 | $this->getAllCombinations($argumentsTail, $newCombination), |
|
25 | $combinations |
||
26 | ); |
||
27 | } |
||
28 | |||
29 | 6 | return $combinations; |
|
30 | } |
||
41 |