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 AllCommand extends Command |
||
12 | { |
||
13 | /** |
||
14 | * The name and signature of the console command. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $signature = 'autotrans:all'; |
||
19 | |||
20 | /** |
||
21 | * The console command description. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $description = 'Translates all source translations to target translations'; |
||
26 | |||
27 | protected $phpTranslator; |
||
28 | protected $jsonTranslator; |
||
29 | |||
30 | protected $targetLanguages; |
||
31 | |||
32 | /** |
||
33 | * Create a new command instance. |
||
34 | * |
||
35 | * @return void |
||
|
|||
36 | */ |
||
37 | View Code Duplication | public function __construct(PhpTranslator $phpTranslator, JsonTranslator $jsonTranslator) |
|
44 | |||
45 | /** |
||
46 | * Execute the console command. |
||
47 | * |
||
48 | * @return mixed |
||
49 | */ |
||
50 | View Code Duplication | public function handle() |
|
82 | |||
83 | private function translateJsonFiles() |
||
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.