Completed
Push — master ( 81e1a1...0dbe46 )
by ARCANEDEV
30:13
created

SetupCommand::publishAllModules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
ccs 0
cts 6
cp 0
rs 9.4286
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php namespace Arcanesoft\Foundation\Console;
2
3
use Arcanedev\Support\Bases\Command;
4
5
/**
6
 * Class     SetupCommand
7
 *
8
 * @package  Arcanesoft\Foundation\Console
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class SetupCommand extends Command
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * The name and signature of the console command.
19
     *
20
     * @var string
21
     */
22
    protected $signature = 'foundation:setup';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = 'Foundation setup command.';
30
31
    /* ------------------------------------------------------------------------------------------------
32
     |  Main Functions
33
     | ------------------------------------------------------------------------------------------------
34
     */
35
    /**
36
     * Execute the console command.
37
     */
38
    public function handle()
39
    {
40
        if ( ! $this->confirm('Do you wish to reset the application ? [y|N]')) {
41
            return;
42
        }
43
44
        $options = $this->getDefaultOptions();
45
46
        $this->publishAllModules($options);
47
        $this->setupAllModules($options);
48
        $this->seedFoundation($options);
49
    }
50
51
    /**
52
     * Get the default options.
53
     *
54
     * @return array
55
     */
56
    private function getDefaultOptions()
57
    {
58
        return $arguments = [
0 ignored issues
show
Unused Code introduced by
$arguments is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
59
            '--quiet' => true,
60
        ];
61
    }
62
63
    /* ------------------------------------------------------------------------------------------------
64
     |  Other Functions
65
     | ------------------------------------------------------------------------------------------------
66
     */
67
    /**
68
     * Publish all modules : configs, migrations, assets ...
69
     *
70
     * @param  array  $options
71
     */
72
    private function publishAllModules(array $options)
73
    {
74
        $this->call('foundation:publish', $options);
75
76
        $this->call('optimize');
77
78
        $this->info('All modules are published !');
79
    }
80
81
    /**
82
     * Setup all modules.
83
     *
84
     * @param  array  $options
85
     */
86
    private function setupAllModules(array $options)
87
    {
88
        $this->call('migrate:refresh', $options);
89
90
        // Setup the auth module.
91
        $this->call('auth:setup', $options);
92
    }
93
94
    /**
95
     * Seed Foundation.
96
     */
97
    private function seedFoundation(array $options)
98
    {
99
        $this->call('db:seed', array_merge($options, [
100
            '--class' => \Arcanesoft\Foundation\Seeds\DatabaseSeeder::class
101
        ]));
102
    }
103
}
104