SettingsServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 10
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 17
ccs 0
cts 0
cp 0
crap 12
rs 9.9332
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