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 |
||
10 | class ReportCommand extends Command |
||
11 | { |
||
12 | /** |
||
13 | * The console command name. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $name = 'ab:report'; |
||
18 | |||
19 | /** |
||
20 | * The console command description. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $description = 'Print the A/B testing report.'; |
||
25 | |||
26 | /** |
||
27 | * Create a new command instance. |
||
28 | * |
||
29 | * @return void |
||
|
|||
30 | */ |
||
31 | public function __construct() |
||
35 | |||
36 | /** |
||
37 | * Execute the console command. |
||
38 | * |
||
39 | * @return mixed |
||
40 | */ |
||
41 | public function handle() |
||
74 | |||
75 | /** |
||
76 | * Get the console command arguments. |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | protected function getArguments() |
||
84 | |||
85 | /** |
||
86 | * Get the console command options. |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | protected function getOptions() |
||
94 | } |
||
95 |
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.