Conditions | 5 |
Paths | 6 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | 3 | public static function fromCollection(BranchCollection $collection = null,array $mapping = []) |
|
8 | { |
||
9 | 3 | $array = []; |
|
10 | |||
11 | 3 | if(empty($collection)) return $array; |
|
12 | |||
13 | 3 | foreach($collection as $branch) |
|
14 | { |
||
15 | 3 | $children = $branch->hasBranches() ? self::fromCollection($branch->branches,$mapping) : null; |
|
16 | 3 | ||
17 | $record = ['id' => $branch->key,'slug' => $branch->value,'name' => $branch->label]; |
||
18 | 3 | if($children) $record['children'] = $children; |
|
19 | 2 | ||
20 | $array[] = $record; |
||
21 | 3 | } |
|
22 | |||
23 | return $array; |
||
24 | } |
||
25 | } |
||
26 |