Test Failed
Push — master ( 5db3d4...8c11ec )
by Derek Stephen
09:45
created

ViewPackage::getMiddleware()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 11
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 1
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\GlobalMiddlewareRegistrationInterface;
0 ignored issues
show
Bug introduced by
The type Bone\Http\GlobalMiddlewareRegistrationInterface 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\Middleware\Stack;
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, GlobalMiddlewareRegistrationInterface
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
    /**
30
     * @param Container $container
31
     * @return array
32
     */
33
    public function getMiddleware(Container $c): array
34
    {
35
        $defaultLayout = $c->get('default_layout');
36
        $errorPages = $c->get('error_pages');
37
        $viewEngine = $c->get(ViewEngine::class);
38
        $layoutMiddleware = new LayoutMiddleware($viewEngine, $defaultLayout);
39
        $exceptionMiddleware = new ExceptionMiddleware($viewEngine, $errorPages);
40
41
        return [
42
            $layoutMiddleware,
43
            $exceptionMiddleware,
44
        ];
45
    }
46
47
    /**
48
     * @param Container $c
49
     * @return array
50
     */
51
    public function getGlobalMiddleware(Container $c): array
52
    {
53
        return [
54
            LayoutMiddleware::class,
55
            ExceptionMiddleware::class
56
        ];
57
    }
58
}
59