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 MigrateStatusCommand extends Command |
||
12 | { |
||
13 | /** |
||
14 | * The console command name. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $name = 'module:migrate-status'; |
||
19 | |||
20 | /** |
||
21 | * The console command description. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $description = 'Status for all module migrations'; |
||
26 | |||
27 | /** |
||
28 | * @var \Nwidart\Modules\Contracts\RepositoryInterface |
||
29 | */ |
||
30 | protected $module; |
||
31 | |||
32 | /** |
||
33 | * Execute the console command. |
||
34 | * |
||
35 | * @return mixed |
||
36 | */ |
||
37 | View Code Duplication | public function handle() : int |
|
58 | |||
59 | /** |
||
60 | * Run the migration from the specified module. |
||
61 | * |
||
62 | * @param Module $module |
||
63 | */ |
||
64 | protected function migrateStatus(Module $module) |
||
73 | |||
74 | /** |
||
75 | * Get the console command arguments. |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | 128 | protected function getArguments() |
|
85 | |||
86 | /** |
||
87 | * Get the console command options. |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | 128 | View Code Duplication | protected function getOptions() |
98 | } |
||
99 |