RouteServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace App\Providers;
5
6
use App\Routing\RoutingErrorResponder;
7
use Illuminate\Container\Container;
8
use N1215\Hakudo\Router;
9
use N1215\Http\Router\Result\RoutingResultFactory;
10
use N1215\Http\Router\RouterInterface;
11
use N1215\Http\Router\Handler\RoutingErrorResponderInterface;
12
use N1215\Jugoya\RequestHandlerBuilderInterface;
13
use N1215\Tsukuyomi\FrameworkInterface;
14
15
class RouteServiceProvider implements ServiceProviderInterface
16
{
17 1
    public function register(Container $container)
18
    {
19
        $container->singleton(RouterInterface::class, function (Container $container) {
20 1
            $framework = $container->get(FrameworkInterface::class);
21 1
            $router = new Router($container->get(RequestHandlerBuilderInterface::class), new RoutingResultFactory());
22
23 1
            $routingPath = $framework->path('routes/api.php');
24 1
            require $routingPath;
25
26 1
            return $router;
27 1
        });
28
29 1
        $container->singleton(RoutingErrorResponderInterface::class, RoutingErrorResponder::class);
30 1
    }
31
}
32