Test Failed
Push — master ( fdaa2f...711c23 )
by Derek Stephen
09:23
created

ViewPackage::addMiddleware()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 9
rs 10
ccs 0
cts 0
cp 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Bone\View;
6
7
use Barnacle\Container;
8
use Barnacle\RegistrationInterface;
9
use Bone\Http\Middleware\Stack;
0 ignored issues
show
Bug introduced by
The type Bone\Http\Middleware\Stack 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...
10
use Bone\Http\MiddlewareAwareInterface;
0 ignored issues
show
Bug introduced by
The type Bone\Http\MiddlewareAwareInterface 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...
11
use Bone\View\Extension\Plates\AlertBox;
12
use Bone\View\Middleware\ExceptionMiddleware;
13
use Bone\View\Middleware\LayoutMiddleware;
14
use Bone\View\ViewEngine;
15
16
class ViewPackage implements RegistrationInterface, MiddlewareAwareInterface
17 1
{
18
    /**
19
     * @param Container $c
20 1
     */
21 1
    public function addToContainer(Container $c)
22
    {
23 1
        // set up the view engine dependencies
24 1
        $viewEngine = new ViewEngine();
25
        $viewEngine->loadExtension(new AlertBox());
26
        $c[ViewEngine::class] = $viewEngine;
27
    }
28
29
    public function addMiddleware(Stack $stack, Container $c): void
30
    {
31
        $defaultLayout = $c->get('default_layout');
32
        $errorPages = $c->get('error_pages');
33
        $viewEngine = $c->get(ViewEngine::class);
34
        $layoutMiddleware = new LayoutMiddleware($viewEngine, $defaultLayout);
35
        $exceptionMiddleware = new ExceptionMiddleware($viewEngine, $errorPages);
36
        $stack->addMiddleWare($layoutMiddleware);
37
        $stack->addMiddleWare($exceptionMiddleware);
38
    }
39
40
41
}
42