AppServiceProvider   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 5
dl 0
loc 49
ccs 0
cts 30
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 21 4
A register() 0 6 2
A setupLdap() 0 7 2
1
<?php
2
3
namespace SET\Providers;
4
5
use Illuminate\Support\Facades\Cache;
6
use Illuminate\Support\ServiceProvider;
7
use SET\Handlers\DBConfigs\DBConfigs;
8
use SET\Setting;
9
10
class AppServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Bootstrap any application services.
14
     *
15
     * @return void
16
     */
17
    public function boot()
18
    {
19
        // Ensure installation is not in progress
20
        if (!strpos(url()->current(), 'install')) {
21
            DBConfigs::execute();
22
            $this->setupLdap();
23
24
            // Force SSL Secure Routes
25
            if (!$this->app->environment('local')) {
0 ignored issues
show
Unused Code introduced by
The call to Application::environment() has too many arguments starting with 'local'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
26
                if (app()::VERSION >= 5.4) {
27
                    \URL::forceScheme('https');    //# Method changed in Laravel 5.4
0 ignored issues
show
Bug introduced by
The method forceScheme() does not exist on Illuminate\Routing\UrlGenerator. Did you maybe mean forceSchema()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
28
                } else {
29
                    \URL::forceSchema('https');
30
                }
31
            }
32
        }
33
34
        Setting::saving(function ($setting) {
35
            Cache::forever($setting->key, $setting->value);
36
        });
37
    }
38
39
    /**
40
     * Register any application services.
41
     *
42
     * @return void
43
     */
44
    public function register()
45
    {
46
        if ($this->app->environment() == 'local') {
47
            $this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
48
        }
49
    }
50
51
    private function setupLdap()
52
    {
53
        if (config('auth.providers.users.driver') == 'adldap') {
54
            $this->app->register('Adldap\Laravel\AdldapServiceProvider');
55
            $this->app->register('Adldap\Laravel\AdldapAuthServiceProvider');
56
        }
57
    }
58
}
59