Passed
Pull Request — master (#11)
by Rustam
12:00
created

PanelCollectionFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 17
ccs 0
cts 7
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A __invoke() 0 11 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Viewer\Factory;
6
7
use Psr\Container\ContainerInterface;
8
use Yiisoft\Yii\Debug\Viewer\PanelCollection;
9
10
class PanelCollectionFactory
11
{
12
    public function __construct(private array $panels)
13
    {
14
    }
15
16
    public function __invoke(ContainerInterface $container): PanelCollection
17
    {
18
        $panels = [];
19
        foreach ($this->panels as $id => $panel) {
20
            if (is_string($panel)) {
21
                $panel = $container->get($panel);
22
            }
23
            $panels[$id] = $panel;
24
        }
25
26
        return new PanelCollection($panels);
27
    }
28
}
29