SettingsServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

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