Completed
Pull Request — master (#166)
by Josh
12:20
created

DisableCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 27.27%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 46
loc 46
ccs 3
cts 11
cp 0.2727
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fire() 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
     * @return mixed
28
     */
29
    public function fire()
30
    {
31
        $module = $this->laravel['modules']->findOrFail($this->argument('module'));
32
33
        if ($module->enabled()) {
34
            $module->disable();
35
36
            $this->info("Module [{$module}] disabled successful.");
37
        } else {
38
            $this->comment("Module [{$module}] has already disabled.");
39
        }
40
    }
41
42
    /**
43
     * Get the console command arguments.
44
     *
45
     * @return array
46
     */
47 43
    protected function getArguments()
48
    {
49
        return array(
50 43
            array('module', InputArgument::REQUIRED, 'Module name.'),
51 43
        );
52
    }
53
}
54