Completed
Pull Request — master (#1085)
by
unknown
54:16 queued 45:25
created

ConsoleServiceProvider::resolveCommands()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 10
ccs 5
cts 5
cp 1
crap 2
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Nwidart\Modules\Providers;
4
5
use Illuminate\Support\Facades\Config;
6
use Illuminate\Support\ServiceProvider;
7
use Nwidart\Modules\Commands\CommandMakeCommand;
8
use Nwidart\Modules\Commands\ControllerMakeCommand;
9
use Nwidart\Modules\Commands\DisableCommand;
10
use Nwidart\Modules\Commands\DumpCommand;
11
use Nwidart\Modules\Commands\EnableCommand;
12
use Nwidart\Modules\Commands\EventMakeCommand;
13
use Nwidart\Modules\Commands\FactoryMakeCommand;
14
use Nwidart\Modules\Commands\InstallCommand;
15
use Nwidart\Modules\Commands\JobMakeCommand;
16
use Nwidart\Modules\Commands\LaravelModulesV6Migrator;
17
use Nwidart\Modules\Commands\ListCommand;
18
use Nwidart\Modules\Commands\ListenerMakeCommand;
19
use Nwidart\Modules\Commands\MailMakeCommand;
20
use Nwidart\Modules\Commands\MiddlewareMakeCommand;
21
use Nwidart\Modules\Commands\MigrateCommand;
22
use Nwidart\Modules\Commands\MigrateRefreshCommand;
23
use Nwidart\Modules\Commands\MigrateResetCommand;
24
use Nwidart\Modules\Commands\MigrateRollbackCommand;
25
use Nwidart\Modules\Commands\MigrateStatusCommand;
26
use Nwidart\Modules\Commands\MigrationMakeCommand;
27
use Nwidart\Modules\Commands\ModelMakeCommand;
28
use Nwidart\Modules\Commands\ModuleDeleteCommand;
29
use Nwidart\Modules\Commands\ModuleMakeCommand;
30
use Nwidart\Modules\Commands\NotificationMakeCommand;
31
use Nwidart\Modules\Commands\PolicyMakeCommand;
32
use Nwidart\Modules\Commands\ProviderMakeCommand;
33
use Nwidart\Modules\Commands\PublishCommand;
34
use Nwidart\Modules\Commands\PublishConfigurationCommand;
35
use Nwidart\Modules\Commands\PublishMigrationCommand;
36
use Nwidart\Modules\Commands\PublishTranslationCommand;
37
use Nwidart\Modules\Commands\RequestMakeCommand;
38
use Nwidart\Modules\Commands\ResourceMakeCommand;
39
use Nwidart\Modules\Commands\RouteProviderMakeCommand;
40
use Nwidart\Modules\Commands\RuleMakeCommand;
41
use Nwidart\Modules\Commands\SeedCommand;
42
use Nwidart\Modules\Commands\SeedMakeCommand;
43
use Nwidart\Modules\Commands\SetupCommand;
44
use Nwidart\Modules\Commands\TestMakeCommand;
45
use Nwidart\Modules\Commands\UnUseCommand;
46
use Nwidart\Modules\Commands\UpdateCommand;
47
use Nwidart\Modules\Commands\UseCommand;
48
49
class ConsoleServiceProvider extends ServiceProvider
50
{
51
52
    /**
53
     * Namespace of the console commands
54
     *
55
     * @var string
56
     */
57
    protected $consoleNamespace = "Nwidart\\Modules\\Commands";
58
59
    /**
60
     * The available commands
61
     *
62
     * @var array
63
     */
64
    protected $commands = [
65
        CommandMakeCommand::class,
66
        ControllerMakeCommand::class,
67
        DisableCommand::class,
68
        DumpCommand::class,
69
        EnableCommand::class,
70
        EventMakeCommand::class,
71
        JobMakeCommand::class,
72
        ListenerMakeCommand::class,
73
        MailMakeCommand::class,
74
        MiddlewareMakeCommand::class,
75
        NotificationMakeCommand::class,
76
        ProviderMakeCommand::class,
77
        RouteProviderMakeCommand::class,
78
        InstallCommand::class,
79
        ListCommand::class,
80
        ModuleDeleteCommand::class,
81
        ModuleMakeCommand::class,
82
        FactoryMakeCommand::class,
83
        PolicyMakeCommand::class,
84
        RequestMakeCommand::class,
85
        RuleMakeCommand::class,
86
        MigrateCommand::class,
87
        MigrateRefreshCommand::class,
88
        MigrateResetCommand::class,
89
        MigrateRollbackCommand::class,
90
        MigrateStatusCommand::class,
91
        MigrationMakeCommand::class,
92
        ModelMakeCommand::class,
93
        PublishCommand::class,
94
        PublishConfigurationCommand::class,
95
        PublishMigrationCommand::class,
96
        PublishTranslationCommand::class,
97
        SeedCommand::class,
98
        SeedMakeCommand::class,
99
        SetupCommand::class,
100
        UnUseCommand::class,
101
        UpdateCommand::class,
102
        UseCommand::class,
103
        ResourceMakeCommand::class,
104
        TestMakeCommand::class,
105
        LaravelModulesV6Migrator::class,
106
    ];
107
108
    /**
109
     * Register the commands.
110
     */
111 100
    public function register()
112
    {
113 100
        $this->commands($this->resolveCommands());
114 100
    }
115
116 100
    private function resolveCommands()
117
    {
118 100
        $commands = [];
119
120 100
        foreach (config('modules.commands', $this->commands) as $command) {
121 100
            $commands[] = $this->consoleNamespace . "\\" . $command;
122
        }
123
124 100
        return $commands;
125
    }
126
127
    /**
128
     * @return array
129
     */
130
    public function provides()
131
    {
132
        $provides = $this->commands;
133
134
        return $provides;
135
    }
136
}
137