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 |
||
11 | class RouteProviderMakeCommand extends GeneratorCommand |
||
12 | { |
||
13 | use ModuleCommandTrait; |
||
14 | |||
15 | protected $argumentName = 'module'; |
||
16 | |||
17 | /** |
||
18 | * The command name. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $name = 'module:route-provider'; |
||
23 | |||
24 | /** |
||
25 | * The command description. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $description = 'Create a new route service provider for the specified module.'; |
||
30 | |||
31 | /** |
||
32 | * The command arguments. |
||
33 | * |
||
34 | * @return array |
||
35 | 95 | */ |
|
36 | protected function getArguments() |
||
42 | |||
43 | protected function getOptions() |
||
49 | 87 | ||
50 | /** |
||
51 | 87 | * Get template contents. |
|
52 | 87 | * |
|
53 | 87 | * @return string |
|
54 | 87 | */ |
|
55 | 87 | View Code Duplication | protected function getTemplateContents() |
69 | |||
70 | /** |
||
71 | * @return string |
||
72 | */ |
||
73 | private function getFileName() |
||
77 | 87 | ||
78 | /** |
||
79 | 87 | * Get the destination file path. |
|
80 | * |
||
81 | 87 | * @return string |
|
82 | */ |
||
83 | protected function getDestinationFilePath() |
||
91 | |||
92 | /** |
||
93 | * @return mixed |
||
94 | */ |
||
95 | 87 | protected function getWebRoutesPath() |
|
99 | |||
100 | 87 | /** |
|
101 | * @return mixed |
||
102 | 87 | */ |
|
103 | protected function getApiRoutesPath() |
||
107 | |||
108 | public function getDefaultNamespace() : string |
||
112 | } |
||
113 |