| Total Complexity | 9 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Utilities |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Convert flat tree structure to nested. |
||
| 11 | * |
||
| 12 | * @param array $flatTree |
||
| 13 | * @param string $levelName |
||
| 14 | * |
||
| 15 | * @return array |
||
| 16 | */ |
||
| 17 | 6 | public static function flatToNested( |
|
| 18 | array $flatTree, |
||
| 19 | string $levelName = 'level' |
||
| 20 | ): array { |
||
| 21 | 6 | return self::_flatToNested($flatTree, $levelName); |
|
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param array $flatTree |
||
| 26 | * @param string $levelName |
||
| 27 | * @param null|int $level |
||
| 28 | * @param int $startPos |
||
| 29 | * @param array $result |
||
| 30 | * |
||
| 31 | * @return array |
||
| 32 | */ |
||
| 33 | 6 | private static function _flatToNested( |
|
| 68 | } |
||
| 69 | } |
||
| 70 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.