Conditions | 4 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public function sortBySections(array $pages): array |
||
20 | { |
||
21 | $result = []; |
||
22 | |||
23 | /** @var PageInterface $page */ |
||
24 | foreach ($pages as $page) { |
||
25 | foreach ($page->getSections() as $section) { |
||
26 | $sectionCode = $section->getCode(); |
||
27 | if (!array_key_exists($sectionCode, $result)) { |
||
28 | $result[$sectionCode] = []; |
||
29 | $result[$sectionCode]['section'] = $section; |
||
30 | } |
||
31 | |||
32 | $result[$sectionCode][] = $page; |
||
33 | } |
||
34 | } |
||
35 | |||
36 | return $result; |
||
37 | } |
||
39 |