Passed
Push — master ( ed297f...604ea4 )
by Giuliano
04:39
created

SamuraiServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 71
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 1
A registerConfigs() 0 9 2
A registerCommands() 0 13 1
A registerFacade() 0 5 1
A registerServices() 0 5 1
1
<?php
2
3
namespace Maestriam\Samurai\Providers;
4
5
use Illuminate\Support\Facades\Config;
6
use Illuminate\Support\ServiceProvider;
7
use Maestriam\Samurai\Console\UseThemeCommand;
8
use Maestriam\Samurai\Console\MakeThemeCommand;
9
use Maestriam\Samurai\Console\MakeIncludeCommand;
10
use Maestriam\Samurai\Console\PublishThemeCommand;
11
use Maestriam\Samurai\Console\MakeComponentCommand;
12
use Maestriam\Samurai\Console\RefreshThemeCommand;
13
use Maestriam\Samurai\Console\InitThemeCommand;
14
use Maestriam\Samurai\Entities\Samurai;
15
16
class SamuraiServiceProvider extends ServiceProvider
17
{
18
    /**
19
     * Ao iniciar o service provider...
20
     *
21
     * @return void
22
     */
23
    public function boot()
24
    {
25
        $this->registerConfigs();
26
        $this->registerFacade();
27
        $this->registerCommands();
28
        $this->registerServices();
29
    }
30
31
    private function registerFacade()
32
    {
33
        $this->app->bind(
34
            'samurai', function () {
35
                return new Samurai();
36
            }
37
        );
38
    }
39
40
    /**
41
     * Registra todos os arquivos de configurações do componente
42
     *
43
     * @return void
44
     */
45
    protected function registerConfigs()
46
    {
47
        $source    = __DIR__.'/../Config/config.php';
48
        $published = config_path('samurai.php');
49
50
        $this->publishes([$source => $published], 'samurai');
51
52
        $config = (is_file($published)) ? $published : $source; 
53
        $this->mergeConfigFrom($config, 'samurai');
54
    }
55
56
    /**
57
     * Registra todos os comandos artisans do Maestriam Samurai
58
     *
59
     * @return void
60
     */
61
    protected function registerCommands()
62
    {
63
        $cmds = [
64
            InitThemeCommand::class,
65
            MakeThemeCommand::class,
66
            MakeComponentCommand::class,
67
            MakeIncludeCommand::class,
68
            PublishThemeCommand::class,
69
            UseThemeCommand::class,
70
            RefreshThemeCommand::class,
71
        ];
72
73
        $this->commands($cmds);
74
    }
75
76
    /**
77
     * Registra todos os serviços que devem ser iniciados
78
     * junto com o pacote
79
     *
80
     * @return void
81
     */
82
    protected function registerServices()
83
    {
84
        $this->app->register(RegistersThemesProvider::class);
85
        $this->app->register(LoadThemesServiceProvider::class);
86
        $this->app->register(RegistersCustomDirectiveProvider::class);
87
    }
88
}
89