ServiceProvider::bootRoutes()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 3
Bugs 0 Features 1
Metric Value
cc 2
eloc 2
c 3
b 0
f 1
nc 2
nop 0
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 6
rs 10
1
<?php
2
3
namespace Slides\Saml2;
4
5
/**
6
 * Class ServiceProvider
7
 *
8
 * @package Slides\Saml2
9
 */
10
class ServiceProvider extends \Illuminate\Support\ServiceProvider
11
{
12
    /**
13
     * Indicates if loading of the provider is deferred.
14
     *
15
     * @var bool
16
     */
17
    protected $defer = false;
18
19
    /**
20
     * Bootstrap the application events.
21
     *
22
     * @return void
23
     */
24
    public function boot()
25
    {
26
        $this->bootMiddleware();
27
        $this->bootRoutes();
28
        $this->bootPublishes();
29
        $this->bootCommands();
30
        $this->loadMigrations();
31
    }
32
33
    /**
34
     * Bootstrap the routes.
35
     *
36
     * @return void
37
     */
38
    protected function bootRoutes()
39
    {
40
        if($this->app['config']['saml2.useRoutes'] == true) {
41
            include __DIR__ . '/Http/routes.php';
42
        }
43
    }
44
45
    /**
46
     * Bootstrap the publishable files.
47
     *
48
     * @return void
49
     */
50
    protected function bootPublishes()
51
    {
52
        $source = __DIR__ . '/../config/saml2.php';
53
54
        $this->publishes([$source => config_path('saml2.php')]);
0 ignored issues
show
Bug introduced by
The function config_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
        $this->publishes([$source => /** @scrutinizer ignore-call */ config_path('saml2.php')]);
Loading history...
55
        $this->mergeConfigFrom($source, 'saml2');
56
    }
57
58
    /**
59
     * Bootstrap the console commands.
60
     *
61
     * @return void
62
     */
63
    protected function bootCommands()
64
    {
65
        $this->commands([
66
            \Slides\Saml2\Commands\CreateTenant::class,
67
            \Slides\Saml2\Commands\UpdateTenant::class,
68
            \Slides\Saml2\Commands\DeleteTenant::class,
69
            \Slides\Saml2\Commands\RestoreTenant::class,
70
            \Slides\Saml2\Commands\ListTenants::class,
71
            \Slides\Saml2\Commands\TenantCredentials::class
72
        ]);
73
    }
74
75
    /**
76
     * Bootstrap the console commands.
77
     *
78
     * @return void
79
     */
80
    protected function bootMiddleware()
81
    {
82
        $this->app['router']->aliasMiddleware('saml2.resolveTenant', \Slides\Saml2\Http\Middleware\ResolveTenant::class);
83
    }
84
85
    /**
86
     * Load the package migrations.
87
     *
88
     * @return void
89
     */
90
    protected function loadMigrations()
91
    {
92
        if (config('saml2.load_migrations', true)) {
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

92
        if (/** @scrutinizer ignore-call */ config('saml2.load_migrations', true)) {
Loading history...
93
            $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
94
        }
95
    }
96
97
    /**
98
     * Get the services provided by the provider.
99
     *
100
     * @return array
101
     */
102
    public function provides()
103
    {
104
        return [];
105
    }
106
}
107