Passed
Pull Request — master (#369)
by Mihai
03:23
created

PhiveInstallCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Zalas\Toolbox\Tool\Command;
4
5
use Zalas\Toolbox\Tool\Command;
6
7
final class PhiveInstallCommand implements Command
8
{
9
    private $alias;
10
    private $bin;
11
    private $unsigned;
12
13 7
    public function __construct(string $alias, string $bin, bool $unsigned)
14
    {
15 7
        $this->alias = $alias;
16 7
        $this->bin = $bin;
17 7
        $this->unsigned = $unsigned;
18
    }
19
20 5
    public function __toString(): string
21
    {
22 5
        $home = \dirname($this->bin);
23
24 5
        return \sprintf(
25 5
            'echo "y" | phive --home %s install %s %s -t %s',
26 5
            $home,
27 5
            $this->unsigned ? '--force-accept-unsigned' : '',
28 5
            $this->alias,
29 5
            $this->bin
30
        );
31
    }
32
}
33