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

EnableCommand::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 12
loc 12
ccs 0
cts 7
cp 0
crap 6
rs 9.8666
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 EnableCommand 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:enable';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Enable 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->disabled()) {
32
            $module->enable();
33
34
            $this->info("Module [{$module}] enabled successful.");
35
        } else {
36
            $this->comment("Module [{$module}] has already enabled.");
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