Completed
Push — version-4 ( 449bed...ddf616 )
by Tyler
04:02
created

LERNServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 96.15%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 39
ccs 25
cts 26
cp 0.9615
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 10 1
A boot() 0 9 1
A handleDeprecatedConfigValues() 0 15 3
1
<?php
2
3
namespace Tylercd100\LERN;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class LERNServiceProvider extends ServiceProvider
8
{
9 84
    public function register()
10
    {
11 84
        $this->mergeConfigFrom(__DIR__.'/../config/lern.php', 'lern');
12
13 84
        $this->handleDeprecatedConfigValues();
14
15 84
        $this->app->singleton('lern', function () {
16 3
            return new LERN;
17 84
        });
18 84
    }
19
20 84
    public function boot()
21
    {
22 84
        $this->publishes([
23 84
            __DIR__.'/../views/exceptions/default.blade.php' => base_path('resources/views/exceptions/default.blade.php'),
24 84
            __DIR__.'/../migrations/2016_03_17_000000_create_lern_tables.php' => base_path('database/migrations/2016_03_17_000000_create_lern_tables.php'),
25 84
            __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 84
            __DIR__.'/../config/lern.php' => base_path('config/lern.php'),
27 84
        ]);
28 84
    }
29
30 84
    protected function handleDeprecatedConfigValues()
31
    {
32
        $renamedConfigValues = [
33
            [
34 84
                'oldName' => 'lern.notify.pushover.user',
35 84
                'newName' => 'lern.notify.pushover.users',
36 84
            ],
37 84
        ];
38
39 84
        foreach ($renamedConfigValues as $renamedConfigValue) {
40 84
            if (config($renamedConfigValue['oldName'])) {
41
                config([$renamedConfigValue['newName'] => config($renamedConfigValue['oldName'])]);
42 3
            }
43 84
        }
44
    }
45
}