Completed
Push — master ( 4fcf54...9a364a )
by Derek Stephen
03:09
created

AppPackage::addToContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 5
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
12
class AppPackage implements RegistrationInterface, RouterConfigInterface
13
{
14
    /**
15
     * @param Container $c
16
     */
17
    public function addToContainer(Container $c)
18
    {
19
        $c[IndexController::class] = $c->factory(function (Container $c) {
20
            $controller = new IndexController();
21
22
            return Init::controller($controller, $c);
23
        });
24
    }
25
26
    /**
27
     * @param Container $c
28
     * @param Router $router
29
     * @return Router
30
     */
31
    public function addRoutes(Container $c, Router $router): Router
32
    {
33
        $router->map('GET', '/', [IndexController::class, 'indexAction']);
34
        $router->map('GET', '/learn', [IndexController::class, 'learnAction']);
35
36
        return $router;
37
    }
38
}
39