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

ConfigController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 9
c 0
b 0
f 0
dl 0
loc 26
ccs 0
cts 8
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A index() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Viewer;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Yiisoft\DataResponse\DataResponseFactoryInterface;
9
10
final class ConfigController
11
{
12
    private DataResponseFactoryInterface $responseFactory;
13
    private PanelCollection $panelCollection;
14
15
    /**
16
     * ConfigController constructor.
17
     */
18
    public function __construct(
19
        DataResponseFactoryInterface $responseFactory,
20
        PanelCollection $panelCollection
21
    ) {
22
        $this->responseFactory = $responseFactory;
23
        $this->panelCollection = $panelCollection;
24
    }
25
26
    /**
27
     * @return ResponseInterface
28
     */
29
    public function index(): ResponseInterface
30
    {
31
        $res = [];
32
        foreach ($this->panelCollection->getPanels() as $id => $panel) {
33
            $res[$id] = $panel->getName();
34
        }
35
        return $this->responseFactory->createResponse($res);
36
    }
37
}
38