Test Failed
Branch feature__set_up_scrutinizer (ea6624)
by Robin
06:04 queued 02:46
created

Begin::handle()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 36
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 36
ccs 0
cts 24
cp 0
rs 9.2408
c 0
b 0
f 0
cc 5
nc 3
nop 0
crap 30
1
<?php
2
3
namespace App\Commands;
4
5
use App\Providers\AppServiceProvider;
6
use App\Support\Database\Database;
7
8
class Begin extends BaseCommand
9
{
10
    /**
11
     * The signature of the command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'begin {home?} {--force}';
16
17
    /**
18
     * The description of the command.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Run initial seeders and set up';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @return void
28
     */
29
    public function handle(): void
30
    {
31
        $force = $this->option('force');
32
        $home = realpath($this->argument('home') ?: $this->cli->currentWorkingDirectory());
0 ignored issues
show
Bug introduced by
It seems like $this->argument('home') ...rrentWorkingDirectory() can also be of type array; however, parameter $path of realpath() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

32
        $home = realpath(/** @scrutinizer ignore-type */ $this->argument('home') ?: $this->cli->currentWorkingDirectory());
Loading history...
33
34
        if (! $force && Database::exists()) {
35
            $this->error("Already began, so we've stopped to avoid wiping your settings.");
36
            $this->error("If you definitely want to continue, you can force with the --force flag.");
37
            return;
38
        }
39
40
        $this->line("================");
41
        $this->line("PREPARING PORTER");
42
        $this->line("================");
43
        $this->line("");
44
45
        if (! file_exists(config('porter.library_path'))) {
46
            mkdir(config('porter.library_path'));
47
        }
48
49
        $this->callSilent('vendor:publish', ['--provider' => AppServiceProvider::class]);
50
51
        Database::ensureExists($force);
0 ignored issues
show
Bug introduced by
$force of type string is incompatible with the type boolean expected by parameter $forceRefresh of App\Support\Database\Database::ensureExists(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

51
        Database::ensureExists(/** @scrutinizer ignore-type */ $force);
Loading history...
52
53
        $this->info("Your Porter settings are stored in ".config('porter.library_path'));
54
        $this->info("");
55
56
        $this->callSilent('home', ['path' => $home]);
57
58
        $this->info("Setting home to {$home}.");
59
        $this->comment("This is the used as the root directory for your sites.");
60
        $this->comment("If this is incorrect, you can change it using the 'porter home' command.");
61
        $this->comment("");
62
63
        $this->info("Retrieving docker images");
64
        $this->porter->pullImages();
65
    }
66
}
67