RepositoryGeneratorServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace OzanAkman\RepositoryGenerator;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class RepositoryGeneratorServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Bootstrap the application events.
11
     *
12
     * @return void
13
     */
14
    public function boot()
15
    {
16
        $this->publishConfig();
17
    }
18
19
    /**
20
     * Register the service provider.
21
     *
22
     * @return void
23
     */
24
    public function register()
25
    {
26
        $this->mergeConfig();
27
        $this->registerCommands();
28
    }
29
30
    /**
31
     * Publish configuration.
32
     */
33
    protected function publishConfig()
34
    {
35
        $configPath = __DIR__.'/../config/repository-generator.php';
36
37
        if (function_exists('config_path')) {
38
            $publishPath = config_path('repository-generator.php');
0 ignored issues
show
Bug introduced by
The function config_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
            $publishPath = /** @scrutinizer ignore-call */ config_path('repository-generator.php');
Loading history...
39
        } else {
40
            $publishPath = base_path('config/repository-generator.php');
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
            $publishPath = /** @scrutinizer ignore-call */ base_path('config/repository-generator.php');
Loading history...
41
        }
42
43
        // Publish config files
44
        $this->publishes([$configPath => $publishPath], 'config');
45
    }
46
47
    /**
48
     * Merges configs.
49
     *
50
     * @return void
51
     */
52
    protected function mergeConfig()
53
    {
54
        $this->mergeConfigFrom(__DIR__.'/../config/repository-generator.php', 'repository-generator');
55
    }
56
57
    /**
58
     * Register package commands.
59
     */
60
    protected function registerCommands()
61
    {
62
        if ($this->app->runningInConsole()) {
63
            $this->commands([
64
                Console\Commands\Generate::class,
65
            ]);
66
        }
67
    }
68
}
69