Completed
Push — dev-tylercd100-laravel-notify-... ( 12b986...028084 )
by Tyler
11:07 queued 43s
created

LERNServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 8
rs 9.4285
ccs 7
cts 7
cp 1
cc 1
eloc 5
nc 1
nop 0
crap 1
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 66
    public function register() {
11 66
        $this->mergeConfigFrom(__DIR__ . '/../config/lern.php', 'lern');
12
13 66
        $this->handleDeprecatedConfigValues();
14
15 66
        $this->app->singleton('lern', function() {
16
            return new LERN;
17 66
        });
18 66
    }
19
20 66
    public function boot()
21
    {
22 66
        $this->publishes([
23 66
            __DIR__ . '/../migrations/2016_03_17_000000_create_lern_tables.php' => base_path('database/migrations/2016_03_17_000000_create_lern_tables.php'),
24 66
            __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'),
25 66
            __DIR__ . '/../config/lern.php' => base_path('config/lern.php'),
26 66
        ]);   
27 66
    }
28
29 66
    protected function handleDeprecatedConfigValues()
30
    {
31
        $renamedConfigValues = [
32
33
            /*
34
             * Earlier versions of the package used filesystems instead of disks
35
             */
36
            [
37 66
                'oldName' => 'lern.notify.pushover.user',
38 66
                'newName' => 'lern.notify.pushover.users',
39 66
            ],
40 66
        ];
41
42 66
        foreach ($renamedConfigValues as $renamedConfigValue) {
43 66
            if (config($renamedConfigValue['oldName'])) {
44
                config([$renamedConfigValue['newName'] => config($renamedConfigValue['oldName'])]);
45
            }
46 66
        }
47
    }
48
}