RepositoryServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 27
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
cc 3
eloc 14
c 3
b 0
f 1
nc 4
nop 0
dl 0
loc 27
rs 9.7998
1
<?php
2
3
namespace Shamaseen\Repository;
4
5
use Illuminate\Support\ServiceProvider;
6
use Shamaseen\Repository\Commands\Generator;
7
use Shamaseen\Repository\Commands\Remover;
8
9
/**
10
 * Class GeneratorServiceProvider.
11
 */
12
class RepositoryServiceProvider extends ServiceProvider
13
{
14
    /**
15
     * Bootstrap services.
16
     */
17
    public function boot()
18
    {
19
        if ($this->app->runningInConsole()) {
20
            $this->commands([
21
                Generator::class,
22
                Remover::class,
23
            ]);
24
        }
25
26
        // configs
27
        $this->publishes([
28
            __DIR__.'/config/repository.php' => config_path('repository.php'),
29
            __DIR__.'/lang/repository.php' => lang_path('en/repository.php'),
30
        ], 'repository');
31
32
        // if the configuration is not published then use the package one
33
        if (null === $this->app['config']->get('repository')) {
34
            $this->app['config']->set('repository', require __DIR__.'/config/repository.php');
35
        }
36
37
        // return either the published config or the package one
38
        $config = $this->app['config']->get('repository');
39
40
        // stubs
41
        $this->publishes([
42
            realpath(__DIR__.'/stubs') => $config['stubs_path'],
43
        ], 'repository-stubs');
44
    }
45
46
    /**
47
     * Register services.
48
     */
49
    public function register()
50
    {
51
        $this->mergeConfigFrom(
52
            __DIR__.'/config/repository.php',
53
            'repository'
54
        );
55
    }
56
}
57