We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
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 |
||
7 | View Code Duplication | class CrudModelBackpackCommand extends GeneratorCommand |
|
|
|||
8 | { |
||
9 | /** |
||
10 | * The console command name. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $name = 'backpack:crud-model'; |
||
15 | |||
16 | /** |
||
17 | * The name and signature of the console command. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $signature = 'backpack:crud-model {name}'; |
||
22 | |||
23 | /** |
||
24 | * The console command description. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $description = 'Generate a Backpack CRUD model'; |
||
29 | |||
30 | /** |
||
31 | * The type of class being generated. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $type = 'Model'; |
||
36 | |||
37 | /** |
||
38 | * Get the stub file for the generator. |
||
39 | * |
||
40 | * @return string |
||
41 | */ |
||
42 | protected function getStub() |
||
46 | |||
47 | /** |
||
48 | * Get the default namespace for the class. |
||
49 | * |
||
50 | * @param string $rootNamespace |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | protected function getDefaultNamespace($rootNamespace) |
||
58 | |||
59 | /** |
||
60 | * Replace the table name for the given stub. |
||
61 | * |
||
62 | * @param string $stub |
||
63 | * @param string $name |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | protected function replaceTable(&$stub, $name) |
||
75 | |||
76 | /** |
||
77 | * Build the class with the given name. |
||
78 | * |
||
79 | * @param string $name |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | protected function buildClass($name) |
||
89 | |||
90 | /** |
||
91 | * Get the console command options. |
||
92 | * |
||
93 | * @return array |
||
94 | */ |
||
95 | protected function getOptions() |
||
101 | } |
||
102 |
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.