Passed
Push — master ( 889900...85cb36 )
by Keoghan
02:57
created

Begin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 84.21%

Importance

Changes 0
Metric Value
wmc 3
eloc 23
dl 0
loc 58
ccs 16
cts 19
cp 0.8421
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 28 3
1
<?php
2
3
namespace App\Commands;
4
5
use App\Exceptions\PorterSetupFailed;
6
use App\Support\Images\Organiser\Organiser as ImageOrganiser;
7
8
class Begin extends BaseCommand
9
{
10
    /**
11
     * The begin command may be run at any time, since it's needed to perform setup.
12
     *
13
     * @var bool
14
     */
15
    protected $porterMustBeSetUp = false;
16
17
    /**
18
     * The signature of the command.
19
     *
20
     * @var string
21
     */
22
    protected $signature = 'begin {home?} {--force}';
23
24
    /**
25
     * The description of the command.
26
     *
27
     * @var string
28
     */
29
    protected $description = 'Run initial seeders and set up';
30
31
    /**
32
     * Execute the console command.
33
     *
34
     * @throws \Exception
35
     *
36
     * @return void
37
     */
38 1
    public function handle(): void
39
    {
40 1
        $this->line('================');
41 1
        $this->line('PREPARING PORTER');
42 1
        $this->line('================');
43 1
        $this->line('');
44
45
        try {
46 1
            $this->porterLibrary->setup($this->app, (bool) $this->option('force'));
0 ignored issues
show
Bug introduced by
It seems like $this->app can also be of type null; however, parameter $app of App\PorterLibrary::setUp() does only seem to accept Illuminate\Contracts\Foundation\Application, 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

46
            $this->porterLibrary->setup(/** @scrutinizer ignore-type */ $this->app, (bool) $this->option('force'));
Loading history...
47
        } catch (PorterSetupFailed $e) {
48
            $this->alert($e->getMessage());
49
50
            return;
51
        }
52
53 1
        $this->info('Your Porter settings are stored in '.$this->porterLibrary->path());
54 1
        $this->info('');
55
56 1
        $home = realpath((string) $this->argument('home') ?: $this->cli->currentWorkingDirectory());
57 1
        $this->callSilent('home', ['path' => $home]);
58
59 1
        $this->info("Setting home to {$home}.");
60 1
        $this->comment('This is the root directory for your sites.');
61 1
        $this->comment("If this is incorrect, you can change it using the 'porter home' command.");
62 1
        $this->comment('');
63
64 1
        $this->info('Retrieving docker images');
65 1
        app(ImageOrganiser::class)->pullImages();
66 1
    }
67
}
68