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 InstallCommand extends Command |
||
12 | { |
||
13 | /** |
||
14 | * The console command name. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $name = 'ab:install'; |
||
19 | |||
20 | /** |
||
21 | * The console command description. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $description = 'Prepare the A/B testing database.'; |
||
26 | |||
27 | /** |
||
28 | * Create a new command instance. |
||
29 | * |
||
30 | * @return void |
||
|
|||
31 | */ |
||
32 | public function __construct() |
||
36 | |||
37 | /** |
||
38 | * Execute the console command. |
||
39 | * |
||
40 | * @return mixed |
||
41 | */ |
||
42 | public function handle() |
||
93 | |||
94 | /** |
||
95 | * Get the console command arguments. |
||
96 | * |
||
97 | * @return array |
||
98 | */ |
||
99 | protected function getArguments() |
||
103 | |||
104 | /** |
||
105 | * Get the console command options. |
||
106 | * |
||
107 | * @return array |
||
108 | */ |
||
109 | protected function getOptions() |
||
113 | } |
||
114 |
Adding a
@return
annotation 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.