| Total Complexity | 4 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class WidgetArrangement implements ArgumentInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @param AbstractBlock $block |
||
| 13 | * @return AbstractBlock[][] |
||
| 14 | */ |
||
| 15 | public function getChildrenInColumns(AbstractBlock $block): array |
||
| 16 | { |
||
| 17 | $children = $block->getLayout()->getChildBlocks($block->getNameInLayout()); |
||
| 18 | return $this->arrange($children); |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param AbstractBlock[] $children |
||
| 23 | * @return AbstractBlock[][] |
||
| 24 | */ |
||
| 25 | public function arrange(array $children): array |
||
| 26 | { |
||
| 27 | $columns = $this->getColumnCount(); |
||
| 28 | $result = []; |
||
| 29 | foreach (array_values($children) as $index => $child) { |
||
| 30 | $result[$index % $columns][] = $child; |
||
| 31 | } |
||
| 32 | return $result; |
||
| 33 | } |
||
| 34 | |||
| 35 | private function getColumnCount(): int |
||
| 38 | } |
||
| 39 | } |
||
| 40 |