Completed
Push — dev-master ( a6778d...d870b5 )
by Derek Stephen
15:27 queued 05:30
created

AppPackage::addToContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
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
12
class AppPackage implements RegistrationInterface, RouterConfigInterface
13
{
14
    /**
15
     * @param Container $c
16
     */
17
    public function addToContainer(Container $c)
18 1
    {
19
        $c[IndexController::class] = $c->factory(function (Container $c) {
20
            $controller = new IndexController();
21 1
22
            return Init::controller($controller, $c);
23 1
        });
24 1
    }
25 1
26
    /**
27
     * @return string
28
     */
29
    public function getEntityPath(): string
30 1
    {
31
        return '';
32 1
    }
33
34
    /**
35
     * @return bool
36
     */
37
    public function hasEntityPath(): bool
38 1
    {
39
        return false;
40 1
    }
41
42
    /**
43
     * @param Container $c
44
     * @param Router $router
45
     * @return Router
46
     */
47
    public function addRoutes(Container $c, Router $router): Router
48 1
    {
49
        $router->map('GET', '/', [IndexController::class, 'indexAction']);
50 1
        $router->map('GET', '/learn', [IndexController::class, 'learnAction']);
51 1
52
        return $router;
53 1
    }
54
}
55