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

ToolbarMiddleware   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 2
b 0
f 0
dl 0
loc 23
ccs 0
cts 7
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 14 1
A __construct() 0 2 1
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\EventDispatcher\Provider\ListenerCollection;
12
use Yiisoft\View\WebView;
0 ignored issues
show
Bug introduced by
The type Yiisoft\View\WebView 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...
13
14
final class ToolbarMiddleware implements MiddlewareInterface
15
{
16
    public function __construct(private ListenerCollection $listenerCollection, private WebView $view)
17
    {
18
    }
19
20
    /**
21
     * @inheritDoc
22
     */
23
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
24
    {
25
        //$this->assetManager->register(ToolbarAsset::class);
26
        $css = file_get_contents(dirname(__DIR__, 2) . '/resources/assets/css/toolbar.css');
27
        $js = file_get_contents(dirname(__DIR__, 2) . '/resources/assets/js/toolbar.js');
28
        $this->view->registerJs($js);
29
        $this->view->registerJs(
30
            <<<JS
31
window.YiiDebug.initToolbar('/debug/viewer/toolbar', '/debug/')
32
JS
33
        );
34
        $this->view->registerCss($css, WebView::POSITION_END);
35
36
        return $handler->handle($request);
37
    }
38
}
39