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 | protected function getArguments() |
||
41 | |||
42 | /** |
||
43 | * Get the console command options. |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | protected function getOptions() |
||
53 | |||
54 | /** |
||
55 | * Get template contents. |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | View Code Duplication | protected function getTemplateContents() |
|
75 | |||
76 | /** |
||
77 | * @return string |
||
78 | */ |
||
79 | private function getFileName() |
||
83 | |||
84 | /** |
||
85 | * Get the destination file path. |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | protected function getDestinationFilePath() |
||
97 | |||
98 | /** |
||
99 | * @return mixed |
||
100 | */ |
||
101 | protected function getWebRoutesPath() |
||
105 | |||
106 | /** |
||
107 | * @return mixed |
||
108 | */ |
||
109 | protected function getApiRoutesPath() |
||
113 | |||
114 | public function getDefaultNamespace() : string |
||
118 | } |
||
119 |