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

ToolbarMiddleware::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 2
ccs 0
cts 0
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\Middleware;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Server\MiddlewareInterface;
10
use Psr\Http\Server\RequestHandlerInterface;
11
use Yiisoft\Assets\AssetManager;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Assets\AssetManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Yiisoft\View\WebView;
13
use Yiisoft\Yii\Debug\Viewer\Asset\ToolbarAsset;
14
15
final class ToolbarMiddleware implements MiddlewareInterface
16
{
17
    public function __construct(private AssetManager $assetManager, private WebView $view)
18
    {
19
    }
20
21
    /**
22
     * @inheritDoc
23
     */
24
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
25
    {
26
        $this->assetManager->register(ToolbarAsset::class);
27
        $this->view->registerJs(
28
            <<<JS
29
window.YiiDebug.initToolbar('/debug/toolbar', '/debug/')
30
JS
31
        );
32
33
        return $handler->handle($request);
34
    }
35
}
36