SettingsServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 95%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 40
ccs 19
cts 20
cp 0.95
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B boot() 0 25 2
A register() 0 6 1
1
<?php
2
3
namespace Merodiro\Settings;
4
5
use Illuminate\Support\ServiceProvider;
6
use Illuminate\Support\Facades\Blade;
7
8
use Merodiro\Settings\Commands\SettingsCache;
9
use Merodiro\Settings\Commands\SettingsClear;
10
use Merodiro\Settings\Observers\SettingObserver;
11
use Merodiro\Settings\Models\Setting;
12
13
class SettingsServiceProvider extends ServiceProvider
14
{
15 44
    public function boot()
16
    {
17 44
        $this->publishes([
18 44
            __DIR__.'/config/settings.php' => config_path('settings.php'),
19 44
        ], 'config');
20
21 44
        $this->mergeConfigFrom(
22 44
            __DIR__.'/config/settings.php',
23 44
            'settings'
24
        );
25
26 44
        $this->loadMigrationsFrom(__DIR__ . '/migrations');
27
28 44
        if ($this->app->runningInConsole()) {
29 44
            $this->commands([
30 44
                SettingsCache::class,
31
                SettingsClear::class
32
            ]);
33
        }
34 44
        Setting::observe(SettingObserver::class);
35
36 44
        Blade::directive('settings', function ($expression) {
37
            return "<?php echo Settings::get($expression); ?>";
38 44
        });
39 44
    }
40
41
    /**
42
     * Register any package services.
43
     *
44
     * @return void
45
     */
46
    public function register()
47
    {
48 44
        $this->app->singleton(SettingsManger::class, function () {
49 26
            return new SettingsManger();
50 44
        });
51 44
    }
52
}
53