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 |
||
13 | class ExportCommand extends Command |
||
14 | { |
||
15 | /** |
||
16 | * The console command name. |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $name = 'ab:export'; |
||
21 | |||
22 | /** |
||
23 | * The console command description. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $description = 'Export the A/B testing repor to a CSV file.'; |
||
28 | |||
29 | /** |
||
30 | * Create a new command instance. |
||
31 | * |
||
32 | * @return void |
||
|
|||
33 | */ |
||
34 | public function __construct() |
||
38 | |||
39 | /** |
||
40 | * Execute the console command. |
||
41 | * |
||
42 | * @return mixed |
||
43 | */ |
||
44 | public function handle() |
||
85 | |||
86 | /** |
||
87 | * Get the console command arguments. |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | protected function getArguments() |
||
97 | |||
98 | /** |
||
99 | * Get the console command options. |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | protected function getOptions() |
||
107 | } |
||
108 |
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.