Test Failed
Pull Request — master (#369)
by Mihai
03:48
created

PhiveInstallCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 13 2
A __construct() 0 5 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 $unsigned;
12
13
    public function __construct(string $alias, string $bin, bool $unsigned)
14
    {
15
        $this->alias = $alias;
16
        $this->bin = $bin;
17
        $this->unsigned = $unsigned;
18
    }
19
20
    public function __toString(): string
21
    {
22
        $home = \dirname($this->bin);
23
        $tmp = md5($this->alias);
24
25
        return \sprintf(
26
            'echo "y" | phive --no-progress --home %s install %s %s -t %s && mv %s/* %s',
27
            $home,
28
            $this->unsigned ? '--force-accept-unsigned' : '',
29
            $this->alias,
30
            $tmp,
31
            $tmp,
32
            $this->bin
33
        );
34
    }
35
}
36