Completed
Push — make-php-ldap-optional ( adae9f )
by Shawn
05:33
created

AppServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 82.35%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 40
ccs 14
cts 17
cp 0.8235
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 12 2
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 164
    public function boot()
18
    {
19
        // Ensure installation is not in progress
20 164
        if (!strpos(url()->current(), 'install')) {
21 164
            DBConfigs::execute();
22 164
            $this->setupLdap();
23
        }
24
25 164
        Setting::saving(function ($setting) {
26 10
            Cache::forever($setting->key, $setting->value);
27 164
        });
28 164
    }
29
30
    /**
31
     * Register any application services.
32
     *
33
     * @return void
34
     */
35 164
    public function register()
36
    {
37 164
        if ($this->app->environment() == 'local') {
38
            $this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
39
        }
40 164
    }
41
42 164
    private function setupLdap()
43
    {
44 164
        if (config('auth.providers.users.driver') == 'adldap') {
45
            $this->app->register('Adldap\Laravel\AdldapServiceProvider');
46
            $this->app->register('Adldap\Laravel\AdldapAuthServiceProvider');
47
        }
48 164
    }
49
}
50