Completed
Push — master ( f77f1a...4a796d )
by Derek Stephen
07:48
created

AppPackage::addViewExtensions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Bone\App;
4
5
use Bone\App\Controller\IndexController;
6
use Bone\Controller\Init;
7
use Bone\Router\Router;
8
use Bone\Router\RouterConfigInterface;
9
use Barnacle\RegistrationInterface;
10
use Barnacle\Container;
11
use Bone\View\ViewRegistrationInterface;
12
13
class AppPackage implements RegistrationInterface, RouterConfigInterface, ViewRegistrationInterface
14
{
15
    /**
16
     * @param Container $c
17 1
     */
18
    public function addToContainer(Container $c)
19
    {
20 1
        $c[IndexController::class] = $c->factory(function (Container $c) {
21
            $controller = new IndexController();
22 1
23 1
            return Init::controller($controller, $c);
24 1
        });
25
    }
26
27
    /**
28
     * @return array
29
     */
30
    public function addViews(): array
31 1
    {
32
        return [
33 1
            'app' => __DIR__ . '/View/index',
34 1
            'error' => __DIR__ . '/View/error',
35
            'layouts' => __DIR__ . '/View/layouts',
36 1
        ];
37
    }
38
39
    /**
40
     * @param Container $c
41
     * @return array
42
     */
43
    public function addViewExtensions(Container $c): array
44
    {
45
        return [];
46
    }
47
48
49
    /**
50
     * @param Container $c
51
     * @param Router $router
52
     * @return Router
53
     */
54
    public function addRoutes(Container $c, Router $router): Router
55
    {
56
        $router->map('GET', '/', [IndexController::class, 'indexAction']);
57
        $router->map('GET', '/learn', [IndexController::class, 'learnAction']);
58
59
        return $router;
60
    }
61
}
62