Passed
Push — #5-add-class-and-force-option ( 879bbf...965cc5 )
by Roy
12:25 queued 02:25
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'), 'synchronizer'
35
        );
36
    }
37
38
    /**
39
     * Register publishments
40
     *
41
     * @return void
42
     */
43
    protected function registerPublishments()
44
    {
45
        $this->publishes([
46
            __DIR__ . '/../config/synchronizer.php' => config_path('synchronizer.php'),
47
        ], 'config');
48
49
        $this->publishes([
50
            __DIR__ . '/../database/migrations/' => database_path('migrations'),
51
        ], 'migrations');
52
    }
53
54
    /**
55
     * Get default configuration file path
56
     *
57
     * @return string
58
     */
59
    public function getDefaultConfigFilePath($configName)
60
    {
61
        return realpath(__DIR__ . "/../config/{$configName}.php");
62
    }
63
64
    /**
65
     * Boot commands
66
     *
67
     * @return void
68
     */
69
    private function bootCommands()
70
    {
71
        if ($this->app->runningInConsole()) {
72
            $this->commands([
73
                MakeSynchronizationCommand::class,
74
                SynchronizeCommand::class,
75
            ]);
76
        }
77
    }
78
}
79