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

ConfigController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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