Passed
Push — master ( ca7167...276d5c )
by Fabian
06:10
created

src/ViewModel/WidgetArrangement.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Firegento\DevDashboard\ViewModel;
4
5
use Magento\Backend\Block\Template;
0 ignored issues
show
The type Magento\Backend\Block\Template was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Magento\Framework\View\Element\AbstractBlock;
7
use Magento\Framework\View\Element\Block\ArgumentInterface;
8
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
36
    {
37
        return 3;
38
    }
39
}