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 |
||
9 | class DatabaseUpgradeCommand extends Command |
||
10 | { |
||
11 | use DatabaseCommandTrait; |
||
12 | use ConfirmableTrait; |
||
13 | |||
14 | /** |
||
15 | * The name and signature of the console command. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $signature = 'database:upgrade |
||
20 | {--seed= : Indicates if the seed task should be re-run.} |
||
21 | {--force : Force the operation to run when in production.} |
||
22 | '; |
||
23 | |||
24 | /** |
||
25 | * The console command description. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $description = 'Database migration to latest version'; |
||
30 | |||
31 | /** |
||
32 | * Execute the console command. |
||
33 | * |
||
34 | * @param \Jumilla\Versionia\Laravel\Migrator $migrator |
||
35 | * |
||
36 | * @return mixed |
||
37 | */ |
||
38 | View Code Duplication | public function handle(Migrator $migrator) |
|
54 | |||
55 | /** |
||
56 | * Migrate dataase to latest version. |
||
57 | * |
||
58 | * @param \Jumilla\Versionia\Laravel\Migrator $migrator |
||
59 | */ |
||
60 | protected function migrateToLatest(Migrator $migrator) |
||
85 | } |
||
86 |