Completed
Pull Request — master (#666)
by reallyli
02:28
created

DisableCommand::getArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 6
loc 6
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nwidart\Modules\Commands;
4
5
use Illuminate\Console\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
8 View Code Duplication
class DisableCommand extends Command
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * The console command name.
12
     *
13
     * @var string
14
     */
15
    protected $name = 'module:disable';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Disable the specified module.';
23
24
    /**
25
     * Execute the console command.
26
     */
27
    public function handle()
28
    {
29
        $module = $this->laravel['modules']->findOrFail($this->argument('module'));
30
31
        if ($module->enabled()) {
32
            $module->disable();
33
34
            $this->info("Module [{$module}] disabled successful.");
35
        } else {
36
            $this->comment("Module [{$module}] has already disabled.");
37
        }
38
    }
39
40
    /**
41
     * Get the console command arguments.
42
     *
43
     * @return array
44
     */
45
    protected function getArguments()
46
    {
47
        return [
48
            ['module', InputArgument::REQUIRED, 'Module name.'],
49
        ];
50
    }
51
}
52