Completed
Push — master ( 9d3d3a...708395 )
by Tyler
04:38
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 1
Bugs 0 Features 0
Metric Value
c 1
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 69
    public function register() {
10 69
        $this->mergeConfigFrom(__DIR__ . '/../config/lern.php', 'lern');
11
12 69
        $this->handleDeprecatedConfigValues();
13
14 69
        $this->app->singleton('lern', function() {
15 3
            return new LERN;
16 69
        });
17 69
    }
18
19 69
    public function boot()
20
    {
21 69
        $this->publishes([
22 69
            __DIR__ . '/../migrations/2016_03_17_000000_create_lern_tables.php' => base_path('database/migrations/2016_03_17_000000_create_lern_tables.php'),
23 69
            __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 69
            __DIR__ . '/../config/lern.php' => base_path('config/lern.php'),
25 69
        ]);   
26 69
    }
27
28 69
    protected function handleDeprecatedConfigValues()
29
    {
30
        $renamedConfigValues = [
31
            [
32 69
                'oldName' => 'lern.notify.pushover.user',
33 69
                'newName' => 'lern.notify.pushover.users',
34 69
            ],
35 69
        ];
36
37 69
        foreach ($renamedConfigValues as $renamedConfigValue) {
38 69
            if (config($renamedConfigValue['oldName'])) {
39
                config([$renamedConfigValue['newName'] => config($renamedConfigValue['oldName'])]);
40
            }
41 69
        }
42
    }
43
}