Completed
Push — master ( 669a19...66585b )
by Derek Stephen
03:26
created

AppPackage::addRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace BoneMvc\Module\App;
4
5
use App\Controller\IndexController;
6
use Bone\Mvc\Controller\Init;
7
use Bone\Mvc\Router\RouterConfigInterface;
8
use Barnacle\RegistrationInterface;
9
use Barnacle\Container;
10
use Bone\OAuth2\Http\Middleware\ResourceServerMiddleware;
11
use League\Route\Router;
12
13
class AppPackage implements RegistrationInterface, RouterConfigInterface
14
{
15
    /**
16
     * @param Container $c
17
     */
18 1
    public function addToContainer(Container $c)
19
    {
20
        $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 string
29
     */
30 1
    public function getEntityPath(): string
31
    {
32 1
        return '';
33
    }
34
35
    /**
36
     * @return bool
37
     */
38 1
    public function hasEntityPath(): bool
39
    {
40 1
        return false;
41
    }
42
43
    /**
44
     * @param Container $c
45
     * @param Router $router
46
     * @return Router
47
     */
48
    public function addRoutes(Container $c, Router $router): Router
49
    {
50
        $router->map('GET', '/', [IndexController::class, 'indexAction']);
51
        $router->map('GET', '/learn', [IndexController::class, 'learnAction']);
52
53
        return $router;
54
    }
55
}
56