MigrateRefreshCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 70
rs 10
c 0
b 0
f 0

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