Completed
Pull Request — master (#112)
by Alessandro
10:33 queued 35s
created

SymfonyProcessWrapper::reset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Paraunit\Process;
6
7
use Paraunit\Configuration\EnvVariables;
8
use Symfony\Component\Process\Process;
9
10
/**
11
 * Class SymfonyProcessWrapper
12
 * @package Paraunit\Process
13
 */
14
class SymfonyProcessWrapper extends AbstractParaunitProcess
15
{
16
    /** @var Process */
17
    private $process;
18
19
    /** @var string */
20
    protected $commandLine;
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function __construct(Process $process, string $filename)
26
    {
27
        parent::__construct($filename);
28 22
        $this->process = $process;
29
    }
30 22
31 22
    public function isTerminated(): bool
32
    {
33
        return $this->process->isTerminated();
34 18
    }
35
36 18
    /**
37
     * @param int $pipelineNumber
38
     */
39
    public function start(int $pipelineNumber)
40
    {
41
        $env = $this->process->getEnv();
42
        $env[EnvVariables::PROCESS_UNIQUE_ID] = $this->getUniqueId();
43
        $env[EnvVariables::PIPELINE_NUMBER] = $pipelineNumber;
44 19
45
        $this->process->setEnv($env);
46 19
        $this->process->start();
47 19
    }
48
49 19
    /**
50 19
     * @return string
51
     * @throws \Symfony\Component\Process\Exception\LogicException
52
     */
53
    public function getOutput(): string
54
    {
55
        return $this->process->getOutput() ?? '';
56
    }
57 11
58
    /**
59 11
     * @return int|null
60
     * @throws \Symfony\Component\Process\Exception\RuntimeException
61
     */
62
    public function getExitCode()
63
    {
64
        return $this->process->getExitCode();
65
    }
66 18
67
    /**
68 18
     * @return string
69
     */
70
    public function getCommandLine(): string
71
    {
72
        return $this->process->getCommandLine();
73
    }
74
}
75