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

ViewPackage   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 2
eloc 11
c 5
b 0
f 1
dl 0
loc 22
rs 10
ccs 5
cts 5
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addToContainer() 0 6 1
A addMiddleware() 0 9 1
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