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 | */ |
||
| 36 | 127 | protected function getArguments() |
|
| 42 | |||
| 43 | 127 | protected function getOptions() |
|
| 49 | |||
| 50 | /** |
||
| 51 | * Get template contents. |
||
| 52 | * |
||
| 53 | * @return string |
||
| 54 | */ |
||
| 55 | 117 | View Code Duplication | protected function getTemplateContents() |
| 70 | |||
| 71 | /** |
||
| 72 | * @return string |
||
| 73 | */ |
||
| 74 | 117 | private function getFileName() |
|
| 78 | |||
| 79 | /** |
||
| 80 | * Get the destination file path. |
||
| 81 | * |
||
| 82 | * @return string |
||
| 83 | */ |
||
| 84 | 117 | protected function getDestinationFilePath() |
|
| 92 | |||
| 93 | /** |
||
| 94 | * @return mixed |
||
| 95 | */ |
||
| 96 | 117 | protected function getWebRoutesPath() |
|
| 100 | |||
| 101 | /** |
||
| 102 | * @return mixed |
||
| 103 | */ |
||
| 104 | 117 | protected function getApiRoutesPath() |
|
| 108 | |||
| 109 | 117 | public function getDefaultNamespace() : string |
|
| 115 | |||
| 116 | /** |
||
| 117 | * @return string |
||
| 118 | */ |
||
| 119 | 117 | private function getControllerNameSpace(): string |
|
| 124 | } |
||
| 125 |