Completed
Pull Request — master (#1163)
by
unknown
01:51
created

MigrateFileToDatabaseCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 2
A getOptions() 0 6 1
1
<?php
2
3
namespace Nwidart\Modules\Commands;
4
5
use Illuminate\Console\Command;
6
use Symfony\Component\Console\Input\InputOption;
7
8
class MigrateFileToDatabaseCommand extends Command
9
{
10
    /**
11
     * The console command name.
12
     *
13
     * @var string
14
     */
15
    protected $name = 'module:migrate-to-database';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Migrate all modules to database management.';
23
24
    /**
25
     * Execute the console command.
26
     */
27
    public function handle(): int
28
    {
29
        if (!config('modules.database_management.enabled')) {
30
            $this->info('This feature only works when database management is on.');
31
32
            return false;
33
        }
34
        $this->laravel['modules']->migrateFileToDatabase($this->option('force'));
35
        $this->info('Migrated.');
36
37
        return 0;
38
    }
39
40
    /**
41
     * Get the console command options.
42
     *
43
     * @return array
44
     */
45
    protected function getOptions()
46
    {
47
        return [
48
            ['force', null, InputOption::VALUE_NONE, 'Force the operation to update database.'],
49
        ];
50
    }
51
}
52