Completed
Push — master ( 9a1463...3718bd )
by Basenko
04:21
created

Artisan::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace MadWeb\Initializer\Actions;
4
5
use Illuminate\Console\Command;
6
7
class Artisan extends Action
8
{
9
    private $command;
10
11
    private $arguments;
12
13 78
    public function __construct(Command $artisanCommand, string $command, array $arguments = [])
14
    {
15 78
        parent::__construct($artisanCommand);
16
17 78
        $this->command = $command;
18 78
        $this->arguments = $arguments;
19 78
    }
20
21 18
    public function title(): string
22
    {
23 18
        return "<comment>Running artisan command:</comment> $this->command (".
24 18
            $this->getArtisanCommnad()
25 18
                ->getApplication()
26 18
                ->find($this->command)
27 18
                ->getDescription().
28 18
            ')';
29
    }
30
31 78
    public function run(): bool
32
    {
33 78
        $artisanCommand = $this->getArtisanCommnad();
34
35 78
        if ($artisanCommand->getOutput()->isVerbose()) {
36 6
            $artisanCommand->getOutput()->newLine();
37
38 6
            return ! $artisanCommand->call($this->command, $this->arguments);
39
        }
40
41 72
        return ! $artisanCommand->callSilent($this->command, $this->arguments);
42
    }
43
}
44