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 |
||
10 | class RouteProviderMakeCommand extends GeneratorCommand |
||
11 | { |
||
12 | use ModuleCommandTrait; |
||
13 | |||
14 | protected $argumentName = 'module'; |
||
15 | |||
16 | /** |
||
17 | * The command name. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $name = 'module:route-provider'; |
||
22 | |||
23 | /** |
||
24 | * The command description. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $description = 'Create a new route service provider for the specified module.'; |
||
29 | |||
30 | /** |
||
31 | * The command arguments. |
||
32 | * |
||
33 | * @return array |
||
34 | */ |
||
35 | 94 | protected function getArguments() |
|
41 | |||
42 | /** |
||
43 | * Get template contents. |
||
44 | * |
||
45 | * @return string |
||
46 | */ |
||
47 | 86 | View Code Duplication | protected function getTemplateContents() |
61 | |||
62 | /** |
||
63 | * @return string |
||
64 | */ |
||
65 | 86 | private function getFileName() |
|
69 | |||
70 | /** |
||
71 | * Get the destination file path. |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | 86 | protected function getDestinationFilePath() |
|
83 | |||
84 | /** |
||
85 | * @return mixed |
||
86 | */ |
||
87 | 86 | protected function getWebRoutesPath() |
|
91 | |||
92 | /** |
||
93 | * @return mixed |
||
94 | */ |
||
95 | 86 | protected function getApiRoutesPath() |
|
99 | |||
100 | 86 | public function getDefaultNamespace() : string |
|
104 | } |
||
105 |