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 MissingCommand extends Command |
||
11 | { |
||
12 | /** |
||
13 | * The name and signature of the console command. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $signature = 'autotrans:missing'; |
||
18 | |||
19 | /** |
||
20 | * The console command description. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $description = 'Translates all source translations that are not set in your target translations'; |
||
25 | |||
26 | protected $autoTranslator; |
||
27 | |||
28 | /** |
||
29 | * Create a new command instance. |
||
30 | * |
||
31 | * @return void |
||
|
|||
32 | */ |
||
33 | public function __construct(AutoTranslate $autoTranslator) |
||
38 | |||
39 | /** |
||
40 | * Execute the console command. |
||
41 | * |
||
42 | * @return mixed |
||
43 | */ |
||
44 | public function handle() |
||
91 | } |
||
92 |
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.