@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $result = []; |
| 30 | 30 | $map = []; |
| 31 | 31 | |
| 32 | - foreach($list as $item) { |
|
| 32 | + foreach ($list as $item) { |
|
| 33 | 33 | $map[MapAccess::get($item, $idField)] = static::wrapItem( |
| 34 | 34 | $item, |
| 35 | 35 | $childrenContainerField, |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | ); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - foreach($map as &$item) { |
|
| 41 | - if(($parentId = static::getParentId($item, $parentIdField, $itemContainerField)) !== null) { |
|
| 40 | + foreach ($map as &$item) { |
|
| 41 | + if (($parentId = static::getParentId($item, $parentIdField, $itemContainerField)) !== null) { |
|
| 42 | 42 | $childrenContainer = &static::getChildrenContainer($map[$parentId], $childrenContainerField); |
| 43 | 43 | $childrenContainer[] = &$item; |
| 44 | 44 | } else { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | /** @var scalar|null $parentId */ |
| 62 | 62 | $parentId = MapAccess::get($item, $parentIdField); |
| 63 | 63 | |
| 64 | - if($parentId !== null) { |
|
| 64 | + if ($parentId !== null) { |
|
| 65 | 65 | return $parentId; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | protected static function &getChildrenContainer(&$item, string $childrenContainerField): array |
| 78 | 78 | { |
| 79 | - if(is_array($item)) { |
|
| 79 | + if (is_array($item)) { |
|
| 80 | 80 | return $item[$childrenContainerField]; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | protected static function wrapItem($item, string $childrenContainerField, string $itemContainerField) |
| 94 | 94 | { |
| 95 | - if(is_array($item)) { |
|
| 95 | + if (is_array($item)) { |
|
| 96 | 96 | $item[$childrenContainerField] = []; |
| 97 | 97 | return $item; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if($item instanceof stdClass) { |
|
| 100 | + if ($item instanceof stdClass) { |
|
| 101 | 101 | $item->{$childrenContainerField} = []; |
| 102 | 102 | return $item; |
| 103 | 103 | } |