Completed
Push — master ( 247ae6...f93a8c )
by Nicolas
03:59
created

MigrateRefreshCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 32%

Importance

Changes 0
Metric Value
dl 0
loc 68
ccs 8
cts 25
cp 0.32
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fire() 0 20 2
A getArguments() 0 6 1
A getOptions() 0 8 1
1
<?php
2
3
namespace Nwidart\Modules\Commands;
4
5
use Illuminate\Console\Command;
6
use Nwidart\Modules\Traits\ModuleCommandTrait;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputOption;
9
10
class MigrateRefreshCommand extends Command
11
{
12
    use ModuleCommandTrait;
13
14
    /**
15
     * The console command name.
16
     *
17
     * @var string
18
     */
19
    protected $name = 'module:migrate-refresh';
20
21
    /**
22
     * The console command description.
23
     *
24
     * @var string
25
     */
26
    protected $description = 'Rollback & re-migrate the modules migrations.';
27
28
    /**
29
     * Execute the console command.
30
     */
31
    public function fire()
32
    {
33
        $this->call('module:migrate-reset', [
34
            'module' => $this->getModuleName(),
35
            '--database' => $this->option('database'),
36
            '--force' => $this->option('force'),
37
        ]);
38
39
        $this->call('module:migrate', [
40
            'module' => $this->getModuleName(),
41
            '--database' => $this->option('database'),
42
            '--force' => $this->option('force'),
43
        ]);
44
45
        if ($this->option('seed')) {
46
            $this->call('module:seed', [
47
                'module' => $this->getModuleName(),
48
            ]);
49
        }
50
    }
51
52
    /**
53
     * Get the console command arguments.
54
     *
55
     * @return array
56
     */
57 55
    protected function getArguments()
58
    {
59
        return array(
60 55
            array('module', InputArgument::OPTIONAL, 'The name of module will be used.'),
61 55
        );
62
    }
63
64
    /**
65
     * Get the console command options.
66
     *
67
     * @return array
68
     */
69 55
    protected function getOptions()
70
    {
71
        return array(
72 55
            array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'),
73 55
            array('force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'),
74 55
            array('seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'),
75 55
        );
76
    }
77
}
78