Completed
Push — develop ( df9395...08456a )
by Abdelrahman
16:28
created

ArtisanServiceProvider::registerJobMakeCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Foundation\Providers;
6
7
use Illuminate\Console\Scheduling\ScheduleRunCommand;
8
use Cortex\Foundation\Console\Commands\JobMakeCommand;
9
use Cortex\Foundation\Console\Commands\RuleMakeCommand;
10
use Cortex\Foundation\Console\Commands\MailMakeCommand;
11
use Illuminate\Console\Scheduling\ScheduleFinishCommand;
12
use Cortex\Foundation\Console\Commands\ModelMakeCommand;
13
use Cortex\Foundation\Console\Commands\EventMakeCommand;
14
use Cortex\Foundation\Console\Commands\PolicyMakeCommand;
15
use Cortex\Foundation\Console\Commands\ConfigMakeCommand;
16
use Cortex\Foundation\Console\Commands\ModuleMakeCommand;
17
use Cortex\Foundation\Console\Commands\SeederMakeCommand;
18
use Cortex\Foundation\Console\Commands\ConsoleMakeCommand;
19
use Cortex\Foundation\Console\Commands\FactoryMakeCommand;
20
use Cortex\Foundation\Console\Commands\RequestMakeCommand;
21
use Cortex\Foundation\Console\Commands\MigrateMakeCommand;
22
use Cortex\Foundation\Console\Commands\ResourceMakeCommand;
23
use Cortex\Foundation\Console\Commands\ProviderMakeCommand;
24
use Cortex\Foundation\Console\Commands\ListenerMakeCommand;
25
use Cortex\Foundation\Console\Commands\DataTableMakeCommand;
26
use Cortex\Foundation\Console\Commands\ControllerMakeCommand;
27
use Cortex\Foundation\Console\Commands\MiddlewareMakeCommand;
28
use Cortex\Foundation\Console\Commands\TransformerMakeCommand;
29
use Cortex\Foundation\Console\Commands\NotificationMakeCommand;
30
use Illuminate\Foundation\Providers\ArtisanServiceProvider as BaseArtisanServiceProvider;
31
32
class ArtisanServiceProvider extends BaseArtisanServiceProvider
33
{
34
    /**
35
     * Indicates if loading of the provider is deferred.
36
     *
37
     * @var bool
38
     */
39
    protected $defer = true;
40
41
    /**
42
     * The commands to be registered.
43
     *
44
     * @var array
45
     */
46
    protected $commands = [
47
        'CacheClear' => 'command.cache.clear',
48
        'CacheForget' => 'command.cache.forget',
49
        'ClearCompiled' => 'command.clear-compiled',
50
        //'ClearResets' => 'command.auth.resets.clear',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
51
        'ConfigCache' => 'command.config.cache',
52
        'ConfigClear' => 'command.config.clear',
53
        'Down' => 'command.down',
54
        'Environment' => 'command.environment',
55
        'KeyGenerate' => 'command.key.generate',
56
        'Migrate' => 'command.migrate',
57
        //'MigrateFresh' => 'command.migrate.fresh',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
58
        'MigrateInstall' => 'command.migrate.install',
59
        'MigrateRefresh' => 'command.migrate.refresh',
60
        'MigrateReset' => 'command.migrate.reset',
61
        'MigrateRollback' => 'command.migrate.rollback',
62
        'MigrateStatus' => 'command.migrate.status',
63
        'Optimize' => 'command.optimize',
64
        'PackageDiscover' => 'command.package.discover',
65
        'Preset' => 'command.preset',
66
        'QueueFailed' => 'command.queue.failed',
67
        'QueueFlush' => 'command.queue.flush',
68
        'QueueForget' => 'command.queue.forget',
69
        'QueueListen' => 'command.queue.listen',
70
        'QueueRestart' => 'command.queue.restart',
71
        'QueueRetry' => 'command.queue.retry',
72
        'QueueWork' => 'command.queue.work',
73
        'RouteCache' => 'command.route.cache',
74
        'RouteClear' => 'command.route.clear',
75
        'RouteList' => 'command.route.list',
76
        'Seed' => 'command.seed',
77
        'ScheduleFinish' => ScheduleFinishCommand::class,
78
        'ScheduleRun' => ScheduleRunCommand::class,
79
        'StorageLink' => 'command.storage.link',
80
        'Up' => 'command.up',
81
        'ViewClear' => 'command.view.clear',
82
    ];
83
84
    /**
85
     * The commands to be registered.
86
     *
87
     * @var array
88
     */
89
    protected $devCommands = [
90
        //'AppName' => 'command.app.name',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
91
        //'AuthMake' => 'command.auth.make',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
92
        'CacheTable' => 'command.cache.table',
93
        'ConfigMake' => 'command.config.make',
94
        'ConsoleMake' => 'command.console.make',
95
        'ControllerMake' => 'command.controller.make',
96
        'DatatableMake' => 'command.datatable.make',
97
        //'EventGenerate' => 'command.event.generate',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
98
        'EventMake' => 'command.event.make',
99
        'FactoryMake' => 'command.factory.make',
100
        'JobMake' => 'command.job.make',
101
        'ListenerMake' => 'command.listener.make',
102
        'MailMake' => 'command.mail.make',
103
        'MiddlewareMake' => 'command.middleware.make',
104
        'MigrateMake' => 'command.migrate.make',
105
        'ModelMake' => 'command.model.make',
106
        'ModuleMake' => 'command.module.make',
107
        'NotificationMake' => 'command.notification.make',
108
        'NotificationTable' => 'command.notification.table',
109
        'PolicyMake' => 'command.policy.make',
110
        'ProviderMake' => 'command.provider.make',
111
        'QueueFailedTable' => 'command.queue.failed-table',
112
        'QueueTable' => 'command.queue.table',
113
        'RequestMake' => 'command.request.make',
114
        'ResourceMake' => 'command.resource.make',
115
        'RuleMake' => 'command.rule.make',
116
        'SeederMake' => 'command.seeder.make',
117
        //'SessionTable' => 'command.session.table',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
118
        'Serve' => 'command.serve',
119
        //'TestMake' => 'command.test.make',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
120
        'TransformerMake' => 'command.transformer.make',
121
        'VendorPublish' => 'command.vendor.publish',
122
    ];
123
124
    /**
125
     * Register the service provider.
126
     *
127
     * @return void
128
     */
129
    public function register()
130
    {
131
        $this->registerCommands($this->commands);
132
133
        if ($this->app->environment('local')) {
0 ignored issues
show
Unused Code introduced by
The call to Application::environment() has too many arguments starting with 'local'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
134
            $this->registerCommands($this->devCommands);
135
        }
136
    }
137
138
    /**
139
     * Register the command.
140
     *
141
     * @return void
142
     */
143
    protected function registerConfigMakeCommand()
144
    {
145
        $this->app->singleton('command.config.make', function ($app) {
146
            return new ConfigMakeCommand($app['files']);
147
        });
148
    }
149
150
    /**
151
     * Register the command.
152
     *
153
     * @return void
154
     */
155
    protected function registerConsoleMakeCommand()
156
    {
157
        $this->app->singleton('command.console.make', function ($app) {
158
            return new ConsoleMakeCommand($app['files']);
159
        });
160
    }
161
162
    /**
163
     * Register the command.
164
     *
165
     * @return void
166
     */
167
    protected function registerControllerMakeCommand()
168
    {
169
        $this->app->singleton('command.controller.make', function ($app) {
170
            return new ControllerMakeCommand($app['files']);
171
        });
172
    }
173
174
    /**
175
     * Register the command.
176
     *
177
     * @return void
178
     */
179
    protected function registerDatatableMakeCommand()
180
    {
181
        $this->app->singleton('command.datatable.make', function ($app) {
182
            return new DataTableMakeCommand($app['files']);
183
        });
184
    }
185
186
    /**
187
     * Register the command.
188
     *
189
     * @return void
190
     */
191
    protected function registerEventMakeCommand()
192
    {
193
        $this->app->singleton('command.event.make', function ($app) {
194
            return new EventMakeCommand($app['files']);
195
        });
196
    }
197
198
    /**
199
     * Register the command.
200
     *
201
     * @return void
202
     */
203
    protected function registerFactoryMakeCommand()
204
    {
205
        $this->app->singleton('command.factory.make', function ($app) {
206
            return new FactoryMakeCommand($app['files']);
207
        });
208
    }
209
210
    /**
211
     * Register the command.
212
     *
213
     * @return void
214
     */
215
    protected function registerJobMakeCommand()
216
    {
217
        $this->app->singleton('command.job.make', function ($app) {
218
            return new JobMakeCommand($app['files']);
219
        });
220
    }
221
222
    /**
223
     * Register the command.
224
     *
225
     * @return void
226
     */
227
    protected function registerListenerMakeCommand()
228
    {
229
        $this->app->singleton('command.listener.make', function ($app) {
230
            return new ListenerMakeCommand($app['files']);
231
        });
232
    }
233
234
    /**
235
     * Register the command.
236
     *
237
     * @return void
238
     */
239
    protected function registerMailMakeCommand()
240
    {
241
        $this->app->singleton('command.mail.make', function ($app) {
242
            return new MailMakeCommand($app['files']);
243
        });
244
    }
245
246
    /**
247
     * Register the command.
248
     *
249
     * @return void
250
     */
251
    protected function registerMiddlewareMakeCommand()
252
    {
253
        $this->app->singleton('command.middleware.make', function ($app) {
254
            return new MiddlewareMakeCommand($app['files']);
255
        });
256
    }
257
258
    /**
259
     * Register the command.
260
     *
261
     * @return void
262
     */
263
    protected function registerMigrateMakeCommand()
264
    {
265
        $this->app->singleton('command.migrate.make', function ($app) {
266
            // Once we have the migration creator registered, we will create the command
267
            // and inject the creator. The creator is responsible for the actual file
268
            // creation of the migrations, and may be extended by these developers.
269
            $creator = $app['migration.creator'];
270
271
            $composer = $app['composer'];
272
273
            return new MigrateMakeCommand($creator, $composer);
274
        });
275
    }
276
277
    /**
278
     * Register the command.
279
     *
280
     * @return void
281
     */
282
    protected function registerModelMakeCommand()
283
    {
284
        $this->app->singleton('command.model.make', function ($app) {
285
            return new ModelMakeCommand($app['files']);
286
        });
287
    }
288
289
    /**
290
     * Register the command.
291
     *
292
     * @return void
293
     */
294
    protected function registerModuleMakeCommand()
295
    {
296
        $this->app->singleton('command.module.make', function ($app) {
297
            return new ModuleMakeCommand($app['files']);
298
        });
299
    }
300
301
    /**
302
     * Register the command.
303
     *
304
     * @return void
305
     */
306
    protected function registerNotificationMakeCommand()
307
    {
308
        $this->app->singleton('command.notification.make', function ($app) {
309
            return new NotificationMakeCommand($app['files']);
310
        });
311
    }
312
313
    /**
314
     * Register the command.
315
     *
316
     * @return void
317
     */
318
    protected function registerPolicyMakeCommand()
319
    {
320
        $this->app->singleton('command.policy.make', function ($app) {
321
            return new PolicyMakeCommand($app['files']);
322
        });
323
    }
324
325
    /**
326
     * Register the command.
327
     *
328
     * @return void
329
     */
330
    protected function registerProviderMakeCommand()
331
    {
332
        $this->app->singleton('command.provider.make', function ($app) {
333
            return new ProviderMakeCommand($app['files']);
334
        });
335
    }
336
337
    /**
338
     * Register the command.
339
     *
340
     * @return void
341
     */
342
    protected function registerRequestMakeCommand()
343
    {
344
        $this->app->singleton('command.request.make', function ($app) {
345
            return new RequestMakeCommand($app['files']);
346
        });
347
    }
348
349
    /**
350
     * Register the command.
351
     *
352
     * @return void
353
     */
354
    protected function registerResourceMakeCommand()
355
    {
356
        $this->app->singleton('command.resource.make', function ($app) {
357
            return new ResourceMakeCommand($app['files']);
358
        });
359
    }
360
361
    /**
362
     * Register the command.
363
     *
364
     * @return void
365
     */
366
    protected function registerRuleMakeCommand()
367
    {
368
        $this->app->singleton('command.rule.make', function ($app) {
369
            return new RuleMakeCommand($app['files']);
370
        });
371
    }
372
373
    /**
374
     * Register the command.
375
     *
376
     * @return void
377
     */
378
    protected function registerSeederMakeCommand()
379
    {
380
        $this->app->singleton('command.seeder.make', function ($app) {
381
            return new SeederMakeCommand($app['files'], $app['composer']);
382
        });
383
    }
384
385
    /**
386
     * Register the command.
387
     *
388
     * @return void
389
     */
390
    protected function registerTransformerMakeCommand()
391
    {
392
        $this->app->singleton('command.transformer.make', function ($app) {
393
            return new TransformerMakeCommand($app['files']);
394
        });
395
    }
396
}
397