ServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 58
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0
wmc 5
lcom 2
cbo 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 8 1
A register() 0 19 2
A registerMigrations() 0 4 1
A provides() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of ibrand/setting.
5
 *
6
 * (c) iBrand <https://www.ibrand.cc>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace iBrand\Component\Setting;
13
14
use iBrand\Component\Setting\Models\SystemSetting;
15
use iBrand\Component\Setting\Repositories\CacheDecorator;
16
use iBrand\Component\Setting\Repositories\EloquentSetting;
17
use iBrand\Component\Setting\Repositories\SettingInterface;
18
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
19
20
/**
21
 * Class ServiceProvider
22
 * @package iBrand\Component\Setting
23
 */
24
class ServiceProvider extends LaravelServiceProvider
25
{
26
    /**
27
     * @var bool
28
     */
29
    protected $defer = true;
30
31
    /**
32
     * boot service provider
33
     */
34 7
    public function boot()
35
    {
36 7
        $this->registerMigrations();
37
38 7
        $this->publishes([
39 7
            __DIR__ . '/config.php' => config_path('ibrand/setting.php'),
40
        ]);
41 7
    }
42
43
    /**
44
     * register service provider
45
     */
46 7
    public function register()
47
    {
48
        // merge configs
49 7
        $this->mergeConfigFrom(
50 7
            __DIR__ . '/config.php', 'ibrand.setting'
51
        );
52
53 7
        $this->app->singleton(SettingInterface::class, function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
54 4
            $repository = new EloquentSetting(new SystemSetting());
55
56 4
            if (!config('ibrand.setting.cache')) {
57 1
                return $repository;
58
            }
59
60 3
            return new CacheDecorator($repository);
61 7
        });
62
63 7
        $this->app->alias(SettingInterface::class, 'system_setting');
64 7
    }
65
66
    /**
67
     * Register Passport's migration files.
68
     */
69 7
    protected function registerMigrations()
70
    {
71 7
        return $this->loadMigrationsFrom(__DIR__ . '/../migrations');
72
    }
73
74
    /**
75
     * @return array
76
     */
77 1
    public function provides()
78
    {
79 1
        return [SettingInterface::class, 'system_setting'];
80
    }
81
}
82