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

DisableCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 44
loc 44
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 12 12 2
A getArguments() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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