RouterPackage   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 1
Metric Value
eloc 11
dl 0
loc 14
rs 10
c 5
b 0
f 1
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A addToContainer() 0 12 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Bone\Router;
6
7
use Barnacle\Container;
8
use Barnacle\RegistrationInterface;
9
use Bone\Router\Command\RouterCommand;
10
use Bone\Router\Command\RouterTreeCommand;
11
use Bone\Router\Router;
12
use League\Route\Strategy\ApplicationStrategy;
13
14
class RouterPackage implements RegistrationInterface
15
{
16
    public function addToContainer(Container $c): void
17
    {
18
        $strategy = new ApplicationStrategy();
19
        $strategy->setContainer($c);
20
        $router = $c[Router::class] = new Router();
21
        $router->setStrategy($strategy);
22
        $consoleCommands = $c->has('consoleCommands') ? $c->get('consoleCommands') : [];
23
        $blockedRoutes = $c->has('blockedRoutes') ? $c->get('blockedRoutes') : [];
24
        $routeMiddleware = $c->has('routeMiddleware') ? $c->get('routeMiddleware') : [];
25
        $consoleCommands[] = new RouterCommand($router, $blockedRoutes, $routeMiddleware);
26
        $consoleCommands[] = new RouterTreeCommand($router);
27
        $c['consoleCommands'] = $consoleCommands;
28
    }
29
}
30