Completed
Push — master ( 7054c5...fb019f )
by Derek Stephen
03:15
created

AppPackage::addToContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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
     */
18 1
    public function addToContainer(Container $c)
19
    {
20 1
        $c[IndexController::class] = $c->factory(function (Container $c) {
21 1
            $controller = new IndexController();
22
23 1
            return Init::controller($controller, $c);
24 1
        });
25 1
    }
26
27
    /**
28
     * @return array
29
     */
30 1
    public function addViews(): array
31
    {
32
        return [
33 1
            'app' => __DIR__ . '/View/index',
34
            'error' => __DIR__ . '/View/error',
35
            'layouts' => __DIR__ . '/View/layouts',
36
        ];
37
    }
38
39
    /**
40
     * @param Container $c
41
     * @return array
42
     */
43 1
    public function addViewExtensions(Container $c): array
44
    {
45 1
        return [];
46
    }
47
48
49
    /**
50
     * @param Container $c
51
     * @param Router $router
52
     * @return Router
53
     */
54 1
    public function addRoutes(Container $c, Router $router): Router
55
    {
56 1
        $router->map('GET', '/', [IndexController::class, 'index']);
57 1
        $router->map('GET', '/learn', [IndexController::class, 'learn']);
58
59 1
        return $router;
60
    }
61
}
62