Conditions | 3 |
Paths | 2 |
Total Lines | 16 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | 1 | public static function permute($items, $perms = []) |
|
16 | { |
||
17 | 1 | if (empty($items)) { |
|
18 | 1 | $return = [$perms]; |
|
19 | } else { |
||
20 | 1 | $return = []; |
|
21 | 1 | for ($i = count($items) - 1; $i >= 0; --$i) { |
|
22 | 1 | $newItems = $items; |
|
23 | 1 | $newPerms = $perms; |
|
24 | 1 | list($foo) = array_splice($newItems, $i, 1); |
|
25 | 1 | array_unshift($newPerms, $foo); |
|
26 | 1 | $return = array_merge($return, static::permute($newItems, $newPerms)); |
|
27 | } |
||
28 | } |
||
29 | 1 | return $return; |
|
30 | } |
||
31 | } |