GdprServiceProvider   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 78
rs 10
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A registerCommands() 0 5 2
A register() 0 4 1
A boot() 0 4 1
A registerRoutes() 0 8 1
A configure() 0 5 1
A offerPublishing() 0 6 2
1
<?php
2
3
namespace Soved\Laravel\Gdpr;
4
5
use Illuminate\Support\Facades\Route;
6
use Illuminate\Support\ServiceProvider;
7
use Soved\Laravel\Gdpr\Console\Commands\Cleanup;
8
9
class GdprServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        $this->registerRoutes();
19
        $this->registerCommands();
20
    }
21
22
    /**
23
     * Register the GDPR routes.
24
     *
25
     * @return void
26
     */
27
    protected function registerRoutes()
28
    {
29
        Route::group([
30
            'prefix'     => config('gdpr.uri'),
31
            'namespace'  => 'Soved\Laravel\Gdpr\Http\Controllers',
32
            'middleware' => config('gdpr.middleware'),
33
        ], function () {
34
            $this->loadRoutesFrom(__DIR__.'/../routes/web.php');
35
        });
36
    }
37
38
    /**
39
     * Register the GDPR commands.
40
     *
41
     * @return void
42
     */
43
    protected function registerCommands()
44
    {
45
        if ($this->app->runningInConsole()) {
46
            $this->commands([
47
                Cleanup::class,
48
            ]);
49
        }
50
    }
51
52
    /**
53
     * Register the application services.
54
     *
55
     * @return void
56
     */
57
    public function register()
58
    {
59
        $this->configure();
60
        $this->offerPublishing();
61
    }
62
63
    /**
64
     * Setup the configuration for GDPR.
65
     *
66
     * @return void
67
     */
68
    protected function configure()
69
    {
70
        $this->mergeConfigFrom(
71
            __DIR__.'/../config/gdpr.php',
72
            'gdpr'
73
        );
74
    }
75
76
    /**
77
     * Setup the resource publishing groups for GDPR.
78
     *
79
     * @return void
80
     */
81
    protected function offerPublishing()
82
    {
83
        if ($this->app->runningInConsole()) {
84
            $this->publishes([
85
                __DIR__.'/../config/gdpr.php' => config_path('gdpr.php'),
86
            ], 'gdpr-config');
87
        }
88
    }
89
}
90