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

PhiveInstallCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 23
ccs 12
cts 12
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 8 3
A __construct() 0 6 1
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 $trust;
12
    private $unsigned;
13
14 10
    public function __construct(string $alias, string $bin, bool $trust = false, bool $unsigned = false)
15
    {
16 10
        $this->alias = $alias;
17 10
        $this->bin = $bin;
18 10
        $this->trust = $trust;
19 10
        $this->unsigned = $unsigned;
20
    }
21
22 7
    public function __toString(): string
23
    {
24 7
        return \sprintf(
25 7
            'phive install -g %s %s %s -t %s',
26 7
            $this->trust ? '--trust-gpg-keys' : '',
27 7
            $this->unsigned ? '--force-accept-unsigned' : '',
28 7
            $this->alias,
29 7
            $this->bin
30
        );
31
    }
32
}
33