Completed
Push — master ( a42c47...ac5b6c )
by recca
01:57
created

ConfigServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 95.45%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 52
ccs 21
cts 22
cp 0.9545
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 8 2
A provides() 0 4 1
A handlePublishes() 0 6 1
A register() 0 14 1
1
<?php
2
3
namespace Recca0120\Config;
4
5
use Illuminate\Contracts\Http\Kernel;
6
use Illuminate\Support\ServiceProvider;
7
use Recca0120\Config\Contracts\Repository;
8
use Recca0120\Config\Middleware\SetConfigRepository;
9
use Recca0120\Config\Repositories\DatabaseRepository;
10
11
class ConfigServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap any application services.
15
     */
16 1
    public function boot(Kernel $kernel)
17
    {
18 1
        $kernel->pushMiddleware(SetConfigRepository::class);
19
20 1
        if ($this->app->runningInConsole() === true) {
21 1
            $this->handlePublishes();
22 1
        }
23 1
    }
24
25
    /**
26
     * Register any application services.
27
     */
28
    public function register()
29
    {
30 1
        $this->app->singleton(Repository::class, function ($app) {
31
            $config = [
32
                'protected' => [
33 1
                    'app',
34 1
                    'auth.defaults.guard',
35 1
                ],
36 1
                'path' => $app->storagePath().'/app/',
37 1
            ];
38
39 1
            return new DatabaseRepository($app['config'], $app->make(Config::class), $app['files'], $config);
40 1
        });
41
    }
42
43
    /**
44
     * Get the services provided by the provider.
45
     *
46
     * @return array
47
     */
48 1
    public function provides()
49
    {
50 1
        return ['config'];
51
    }
52
53
    /**
54
     * handle publishes.
55
     */
56 1
    protected function handlePublishes()
57
    {
58 1
        $this->publishes([
59 1
            __DIR__.'/../database/migrations/' => $this->app->databasePath().'/migrations',
60 1
        ], 'migrations');
61 1
    }
62
}
63