Passed
Push — master ( 9db4fb...a44597 )
by Roy
14:32 queued 50s
created

ServiceProvider::getDefaultConfigFilePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace LaravelSynchronize\Providers;
4
5
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
6
use LaravelSynchronize\Console\Commands\MakeSynchronizationCommand;
7
use LaravelSynchronize\Console\Commands\SynchronizeCommand;
8
9
/**
10
 * Service provider
11
 */
12
class ServiceProvider extends BaseServiceProvider
13
{
14
    /**
15
     * Bootstrap the application services.
16
     *
17
     * @return void
18
     */
19
    public function boot()
20
    {
21
        $this->registerPublishments();
22
23
        $this->bootCommands();
24
    }
25
26
    /**
27
     * Register any application services.
28
     *
29
     * @return void
30
     */
31
    public function register()
32
    {
33
        $this->mergeConfigFrom(
34
            $this->getDefaultConfigFilePath('synchronizer'),
35
            'synchronizer'
36
        );
37
    }
38
39
    /**
40
     * Register publishments
41
     *
42
     * @return void
43
     */
44
    protected function registerPublishments()
45
    {
46
        $this->publishes([
47
            __DIR__ . '/../config/synchronizer.php' => config_path('synchronizer.php'),
48
        ], 'config');
49
50
        $this->publishes([
51
            __DIR__ . '/../database/migrations/' => database_path('migrations'),
52
        ], 'migrations');
53
    }
54
55
    /**
56
     * Get default configuration file path
57
     *
58
     * @return string
59
     */
60
    public function getDefaultConfigFilePath($configName)
61
    {
62
        return realpath(__DIR__ . "/../config/{$configName}.php");
63
    }
64
65
    /**
66
     * Boot commands
67
     *
68
     * @return void
69
     */
70
    private function bootCommands()
71
    {
72
        if ($this->app->runningInConsole()) {
73
            $this->commands([
74
                MakeSynchronizationCommand::class,
75
                SynchronizeCommand::class,
76
            ]);
77
        }
78
    }
79
}
80