Completed
Push — master ( 458505...cd7bb2 )
by recca
02:48
created

ScaffoldMakeCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 12.28 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 7
loc 57
ccs 0
cts 15
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getArguments() 0 6 1
A getOptions() 7 7 1
A handle() 0 10 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 Recca0120\Generator\Console;
4
5
use Illuminate\Console\Command;
6
use Symfony\Component\Console\Input\InputOption;
7
use Symfony\Component\Console\Input\InputArgument;
8
9
class ScaffoldMakeCommand extends Command
10
{
11
    /**
12
     * The console command name.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'generate:scaffold';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Create a new scaffold';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return bool|null
29
     */
30
    public function handle()
31
    {
32
        $name = $this->argument('name');
33
34
        $this->call('generate:controller', ['name' => $name]);
35
        $this->call('generate:view', ['name' => $name, '--view' => 'index']);
36
        $this->call('generate:view', ['name' => $name, '--view' => 'create']);
37
        $this->call('generate:view', ['name' => $name, '--view' => 'edit']);
38
        $this->call('generate:view', ['name' => $name, '--view' => '_form']);
39
    }
40
41
    /**
42
     * Get the console command arguments.
43
     *
44
     * @return array
45
     */
46
    protected function getArguments()
47
    {
48
        return [
49
            ['name', InputArgument::REQUIRED, 'The name of the class'],
50
        ];
51
    }
52
53
    /**
54
     * Get the console command options.
55
     *
56
     * @return array
57
     */
58 View Code Duplication
    protected function getOptions()
0 ignored issues
show
Duplication introduced by
This method 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...
59
    {
60
        return [
61
            ['extend', '', InputOption::VALUE_OPTIONAL, 'controller extend.'],
62
            ['view', '', InputOption::VALUE_OPTIONAL, 'view'],
63
        ];
64
    }
65
}
66