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 |
||
| 9 | class UpdateCommand extends Command |
||
| 10 | { |
||
| 11 | use ModuleCommandTrait; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * The console command name. |
||
| 15 | * |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected $name = 'module:update'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * The console command description. |
||
| 22 | * |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | protected $description = 'Update dependencies for the specified module or for all modules.'; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Execute the console command. |
||
| 29 | */ |
||
| 30 | View Code Duplication | public function handle() |
|
| 45 | |||
| 46 | protected function updateModule($name) |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Get the console command arguments. |
||
| 57 | * |
||
| 58 | * @return array |
||
| 59 | */ |
||
| 60 | 92 | protected function getArguments() |
|
| 66 | } |
||
| 67 |