Passed
Push — master ( 159b17...86ca6d )
by Rustam
02:24
created

PanelCollectionFactory::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 11
ccs 0
cts 7
cp 0
rs 10
cc 3
nc 3
nop 1
crap 12
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