GuardianServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 40
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 12 1
A register() 0 14 2
1
<?php
2
3
namespace EmilMoe\Guardian;
4
5
use Illuminate\Support\ServiceProvider;
6
use EmilMoe\Guardian\Http\Middleware\GuardianMiddleware;
7
8
class GuardianServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Perform post-registration booting of services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        $this->publishes([
18
            __DIR__ .'/config/guardian.php' => config_path('guardian.php'),
19
            'config']);
20
21
        $this->publishes([
22
            __DIR__ .'/database/migrations/' => database_path('migrations'),
23
            'migrations']);
24
25
        $this->mergeConfigFrom(__DIR__ .'/config/guardian.php', 'guardian');
26
    }
27
28
    /**
29
     * Register any package services.
30
     *
31
     * @return void
32
     */
33
    public function register()
34
    {
35
        $router = $this->app['router'];
36
        $router->middleware('guard', GuardianMiddleware::class);
37
38
        if (config('guardian.api.enabled'))
39
            $router->group([
40
                'namespace'  => 'EmilMoe\Guardian\Http\Controllers',
41
                'prefix'     => config('guardian.api.url'),
42
                'middleware' => 'auth'
43
            ], function () {
44
                require __DIR__ .'/Http/routes.php';
45
            });
46
    }
47
}