SettingsServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 15
c 2
b 0
f 0
dl 0
loc 41
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 17 3
A register() 0 8 1
1
<?php
2
3
namespace Bavix\Settings;
4
5
use Bavix\Settings\Services\ReadableService;
6
use Illuminate\Support\ServiceProvider;
7
8
class SettingsServiceProvider extends ServiceProvider
9
{
10
11
    /**
12
     * Bootstrap services.
13
     *
14
     * @return void
15
     * @codeCoverageIgnore
16
     */
17
    public function boot(): void
18
    {
19
        if (!$this->app->runningInConsole()) {
20
            return;
21
        }
22
23
        if (function_exists('config_path')) {
24
            $this->publishes([
25
                dirname(__DIR__) . '/config/config.php' => config_path('bavix-settings.php'),
26
            ], 'laravel-settings-config');
27
        }
28
29
        $this->publishes([
30
            dirname(__DIR__) . '/database/' => database_path('migrations'),
31
        ], 'laravel-settings-migrations');
32
33
        $this->loadMigrationsFrom([__DIR__ . '/../database']);
34
    }
35
36
    /**
37
     * Register services.
38
     *
39
     * @return void
40
     */
41 35
    public function register(): void
42
    {
43 35
        $this->mergeConfigFrom(
44 35
            dirname(__DIR__) . '/config/config.php',
45 35
            'bavix-settings'
46
        );
47
48 35
        $this->app->singleton(ReadableService::class, config('bavix-settings.services.readable'));
49 35
    }
50
51
}
52