Passed
Pull Request — master (#7)
by Koen
04:12
created

RouteServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Providers;
6
7
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
8
use Illuminate\Routing\Router;
9
10
final class RouteServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * This namespace is applied to your controller routes.
14
     *
15
     * In addition, it is set as the URL generator's root namespace.
16
     *
17
     * @var string
18
     */
19
    protected $namespace = 'App\Http\Controllers';
20
21
    /**
22
     * Define the routes for the application.
23
     *
24
     * @return void
25
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
26
     */
27 58
    public function map(): void
28
    {
29 58
        $router = $this->app->make(Router::class);
30
31 58
        $this->mapApiRoutes($router);
32
33 58
        $this->mapWebRoutes($router);
34 58
    }
35
36
    /**
37
     * Define the "web" routes for the application.
38
     *
39
     * These routes all receive session state, CSRF protection, etc.
40
     *
41
     * @param  \Illuminate\Routing\Router $router
42
     * @return void
43
     */
44 58
    protected function mapWebRoutes(Router $router): void
45
    {
46 58
        $router->middleware('web')
47 58
            ->namespace($this->namespace)
48 58
            ->group(base_path('routes/web.php'));
49 58
    }
50
51
    /**
52
     * Define the "api" routes for the application.
53
     *
54
     * These routes are typically stateless.
55
     *
56
     * @param  \Illuminate\Routing\Router $router
57
     * @return void
58
     */
59 58
    protected function mapApiRoutes(Router $router): void
60
    {
61 58
        $router->middleware('api')
62 58
            ->namespace($this->namespace)
63 58
            ->group(base_path('routes/api.php'));
64 58
    }
65
}
66