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 |
||
| 7 | View Code Duplication | class Int2stringCharacters extends Command |
|
| 8 | { |
||
| 9 | /** |
||
| 10 | * The name and signature of the console command. |
||
| 11 | * |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | protected $signature = 'int2string:characters |
||
| 15 | {--show : Display the characters instead of modifying the config file} |
||
| 16 | {--c|characters=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ : Generate with custom characters}'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The console command description. |
||
| 20 | * |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $description = 'Set characters for Helper::int2string.'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Execute the console command. |
||
| 27 | * |
||
| 28 | * @return mixed |
||
| 29 | */ |
||
| 30 | public function handle() |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Generate random characters. |
||
| 47 | * |
||
| 48 | * @return string |
||
| 49 | */ |
||
| 50 | protected function generateRandomCharacters($characters) |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Set the characters in the environment file. |
||
| 57 | * |
||
| 58 | * @param string $characters |
||
| 59 | */ |
||
| 60 | protected function setCharactersInEnvironmentFile($characters) |
||
| 74 | } |
||
| 75 |