Completed
Push — dev-tylercd100-laravel-notify-... ( 27f33d )
by Tyler
08:22
created

LERNServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 88.46%

Importance

Changes 6
Bugs 1 Features 1
Metric Value
wmc 5
c 6
b 1
f 1
lcom 1
cbo 3
dl 0
loc 43
ccs 23
cts 26
cp 0.8846
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 11 1
A boot() 0 8 1
A handleDeprecatedConfigValues() 0 19 3
1
<?php
2
3
namespace Tylercd100\LERN;
4
5
use Illuminate\Support\ServiceProvider;
6
use Tylercd100\Notify\Providers\NotifyServiceProvider;
7
8
class LERNServiceProvider extends ServiceProvider
9
{
10 63
    public function register() {
11 63
        $this->mergeConfigFrom(__DIR__ . '/../config/lern.php', 'lern');
12
13 63
        $this->handleDeprecatedConfigValues();
14
15 63
        $this->app->register(NotifyServiceProvider::class);
16
17 63
        $this->app->singleton('lern', function() {
18
            return new LERN;
19 63
        });
20 63
    }
21
22 63
    public function boot()
23
    {
24 63
        $this->publishes([
25 63
            __DIR__ . '/../migrations/2016_03_17_000000_create_lern_tables.php' => base_path('database/migrations/2016_03_17_000000_create_lern_tables.php'),
26 63
            __DIR__ . '/../migrations/2016_03_27_000000_add_user_data_and_url_to_lern_tables.php' => base_path('database/migrations/2016_03_27_000000_add_user_data_and_url_to_lern_tables.php'),
27 63
            __DIR__ . '/../config/lern.php' => base_path('config/lern.php'),
28 63
        ]);   
29 63
    }
30
31 63
    protected function handleDeprecatedConfigValues()
32
    {
33
        $renamedConfigValues = [
34
35
            /*
36
             * Earlier versions of the package used filesystems instead of disks
37
             */
38
            [
39 63
                'oldName' => 'lern.notify.pushover.user',
40 63
                'newName' => 'lern.notify.pushover.users',
41 63
            ],
42 63
        ];
43
44 63
        foreach ($renamedConfigValues as $renamedConfigValue) {
45 63
            if (config($renamedConfigValue['oldName'])) {
46
                config([$renamedConfigValue['newName'] => config($renamedConfigValue['oldName'])]);
47
            }
48 63
        }
49
    }
50
}