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 SettingsCache extends Command |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * The name and signature of the console command. |
||
| 13 | * |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $signature = 'settings:cache {--model=}'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The console command description. |
||
| 20 | * |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $description = 'Cache all settings'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Create a new command instance. |
||
| 27 | * |
||
| 28 | * @return void |
||
|
|
|||
| 29 | */ |
||
| 30 | 44 | public function __construct() |
|
| 34 | |||
| 35 | /** |
||
| 36 | * Execute the console command. |
||
| 37 | * |
||
| 38 | * @return mixed |
||
| 39 | */ |
||
| 40 | 4 | public function handle() |
|
| 68 | } |
||
| 69 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.