Completed
Pull Request — master (#1085)
by
unknown
02:08
created

ConsoleServiceProvider::resolveCommands()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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