Completed
Pull Request — master (#11)
by
unknown
02:46
created

Artisan::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 9
cp 0
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
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
    public function __construct(Command $artisanCommand, string $command, array $arguments = [])
14
    {
15
        parent::__construct($artisanCommand);
16
17
        $this->command = $command;
18
        $this->arguments = $arguments;
19
    }
20
21
    public function title(): string
22
    {
23
        return "<comment>Run artisan command:</comment> $this->command (".
24
            $this->getArtisanCommnad()
25
                ->getApplication()
26
                ->find($this->command)
27
                ->getDescription().
28
            ')';
29
    }
30
31
    public function run(): bool
32
    {
33
        $artisanCommand = $this->getArtisanCommnad();
34
35
        if ($artisanCommand->getOutput()->isVerbose()) {
36
            $artisanCommand->getOutput()->newLine();
37
38
            return ! $artisanCommand->call($this->command, $this->arguments);
39
        }
40
41
        return ! $artisanCommand->callSilent($this->command, $this->arguments);
42
    }
43
}
44