Completed
Pull Request — master (#109)
by Jan Philipp
01:37
created

ProcessValueProvider::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Psh\Config;
4
5
use Symfony\Component\Process\Process;
6
use function trim;
7
8
/**
9
 * Enables lazy initialization of variables
10
 */
11
class ProcessValueProvider implements ValueProvider
12
{
13
    /**
14
     * @var Process
15
     */
16
    private $process;
17
18
    public function __construct(Process $process)
19
    {
20
        $this->process = $process;
21
    }
22
23
    /**
24
     * @return mixed
25
     */
26
    public function getValue(): string
27
    {
28
        $this->process->mustRun();
29
30
        return trim($this->process->getOutput());
31
    }
32
33
    public function getCommand(): string
34
    {
35
        return $this->process->getCommandLine();
36
    }
37
}
38