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

IndexController::panel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
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 4
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 Psr\Http\Message\ServerRequestInterface;
9
use Yiisoft\DataResponse\DataResponseFactoryInterface;
10
use Yiisoft\Router\CurrentRoute;
11
12
final class IndexController
13
{
14
    private DataResponseFactoryInterface $responseFactory;
15
16
    /**
17
     * IndexController constructor.
18
     */
19
    public function __construct(
20
        DataResponseFactoryInterface $responseFactory
21
    ) {
22
        $this->responseFactory = $responseFactory;
23
    }
24
25
    /**
26
     * @return ResponseInterface
27
     */
28
    public function index(): ResponseInterface
29
    {
30
        return $this->responseFactory->createResponse(file_get_contents(dirname(__DIR__) . '/resources/views/index.html'));
31
    }
32
33
    public function panel(CurrentRoute $currentRoute, PanelCollection $panelCollection): ResponseInterface
34
    {
35
        $panel = $panelCollection->getPanel($currentRoute->getArgument('panel'));
0 ignored issues
show
Bug introduced by
It seems like $currentRoute->getArgument('panel') can also be of type null; however, parameter $id of Yiisoft\Yii\Debug\Viewer...lCollection::getPanel() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
        $panel = $panelCollection->getPanel(/** @scrutinizer ignore-type */ $currentRoute->getArgument('panel'));
Loading history...
36
        return $this->responseFactory->createResponse($panel->renderDetail());
37
    }
38
39
    public function toolbar(ServerRequestInterface $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    public function toolbar(/** @scrutinizer ignore-unused */ ServerRequestInterface $request)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41
        return $this->responseFactory->createResponse();
42
    }
43
}
44