LERNServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
ccs 8
cts 8
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Tylercd100\LERN;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class LERNServiceProvider extends ServiceProvider
8
{
9 108
    public function register()
10
    {
11 108
        $this->mergeConfigFrom(__DIR__.'/../config/lern.php', 'lern');
12
13 108
        $this->handleDeprecatedConfigValues();
14
15 108
        $this->app->singleton('lern', function () {
16 3
            return new LERN;
17 108
        });
18 108
    }
19
20 108
    public function boot()
21
    {
22 108
        $this->publishes([
23 108
            __DIR__.'/../views/exceptions/default.blade.php' => base_path('resources/views/exceptions/default.blade.php'),
24 108
            __DIR__.'/../migrations/2016_03_17_000000_create_lern_tables.php' => base_path('database/migrations/2016_03_17_000000_create_lern_tables.php'),
25 108
            __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'),
26 108
            __DIR__.'/../migrations/2017_09_23_000000_add_ip_to_lern_tables.php' => base_path('database/migrations/2017_09_23_000000_add_ip_to_lern_tables.php'),
27 108
            __DIR__.'/../config/lern.php' => base_path('config/lern.php'),
28
        ]);
29 108
    }
30
31 108
    protected function handleDeprecatedConfigValues()
32
    {
33
        $renamedConfigValues = [
34
            [
35 108
                'oldName' => 'lern.notify.pushover.user',
36
                'newName' => 'lern.notify.pushover.users',
37
            ],
38
        ];
39
40 108
        foreach ($renamedConfigValues as $renamedConfigValue) {
41 108
            if (config($renamedConfigValue['oldName'])) {
42 108
                config([$renamedConfigValue['newName'] => config($renamedConfigValue['oldName'])]);
43
            }
44
        }
45 108
    }
46
}
47