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

handleDeprecatedConfigValues()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3.054

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
ccs 9
cts 11
cp 0.8182
rs 9.4285
cc 3
eloc 7
nc 3
nop 0
crap 3.054
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
}