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