Conditions | 4 |
Paths | 5 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
32 | 36 | public static function parseRelationshipPaths(array $paths) |
|
33 | { |
||
34 | 36 | $tree = []; |
|
35 | |||
36 | 36 | foreach ($paths as $path) { |
|
37 | 15 | list($primary, $nested) = array_pad(explode('.', $path, 2), 2, null); |
|
38 | |||
39 | 15 | if (! isset($tree[$primary])) { |
|
40 | 15 | $tree[$primary] = []; |
|
41 | 15 | } |
|
42 | |||
43 | 15 | if ($nested) { |
|
44 | 3 | $tree[$primary][] = $nested; |
|
45 | 3 | } |
|
46 | 36 | } |
|
47 | |||
48 | 36 | return $tree; |
|
49 | } |
||
50 | } |
||
51 |