| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 142 | private static function getPowerSet(array $set): array |
|
| 28 | { |
||
| 29 | 142 | $results = [[]]; |
|
| 30 | |||
| 31 | 142 | foreach ($set as $element) { |
|
| 32 | 142 | foreach ($results as $combination) { |
|
| 33 | 142 | $subset = array_merge([$element], $combination); |
|
| 34 | 142 | $results[] = $subset; |
|
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | 142 | usort( |
|
| 39 | 142 | $results, |
|
| 40 | 142 | function (array $left, array $right): int { |
|
| 41 | 142 | return count($left) <=> count($right); |
|
| 42 | 142 | } |
|
| 43 | ); |
||
| 44 | |||
| 45 | 142 | return array_filter($results); |
|
| 46 | } |
||
| 47 | |||
| 66 |