Completed
Pull Request — master (#24)
by Tyler
05:56 queued 03:40
created

handleDeprecatedConfigValues()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3.054

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 15
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
7
class LERNServiceProvider extends ServiceProvider
8
{
9 66
    public function register() {
10 66
        $this->mergeConfigFrom(__DIR__ . '/../config/lern.php', 'lern');
11
12 66
        $this->handleDeprecatedConfigValues();
13
14 66
        $this->app->singleton('lern', function() {
15
            return new LERN;
16 66
        });
17 66
    }
18
19 66
    public function boot()
20
    {
21 66
        $this->publishes([
22 66
            __DIR__ . '/../migrations/2016_03_17_000000_create_lern_tables.php' => base_path('database/migrations/2016_03_17_000000_create_lern_tables.php'),
23 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'),
24 66
            __DIR__ . '/../config/lern.php' => base_path('config/lern.php'),
25 66
        ]);   
26 66
    }
27
28 66
    protected function handleDeprecatedConfigValues()
29
    {
30
        $renamedConfigValues = [
31
            [
32 66
                'oldName' => 'lern.notify.pushover.user',
33 66
                'newName' => 'lern.notify.pushover.users',
34 66
            ],
35 66
        ];
36
37 66
        foreach ($renamedConfigValues as $renamedConfigValue) {
38 66
            if (config($renamedConfigValue['oldName'])) {
39
                config([$renamedConfigValue['newName'] => config($renamedConfigValue['oldName'])]);
40
            }
41 66
        }
42
    }
43
}