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 MigrateCommand extends Command |
||
12 | { |
||
13 | /** |
||
14 | * The console command name. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $name = 'module:migrate'; |
||
19 | |||
20 | /** |
||
21 | * The console command description. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $description = 'Migrate the migrations from the specified module or from all modules.'; |
||
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 |
|
59 | |||
60 | /** |
||
61 | * Run the migration from the specified module. |
||
62 | * |
||
63 | * @param Module $module |
||
64 | */ |
||
65 | protected function migrate(Module $module) |
||
84 | |||
85 | /** |
||
86 | * Get the console command arguments. |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | 128 | protected function getArguments() |
|
96 | |||
97 | /** |
||
98 | * Get the console command options. |
||
99 | * |
||
100 | * @return array |
||
101 | */ |
||
102 | 128 | protected function getOptions() |
|
113 | } |
||
114 |