Completed
Pull Request — master (#112)
by Alessandro
10:11
created

ProcessFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Paraunit\Process;
6
7
use Paraunit\Configuration\EnvVariables;
8
use Paraunit\Configuration\PHPUnitConfig;
9
use Paraunit\Configuration\TempFilenameFactory;
10
use Symfony\Component\Process\Process;
11
12
/**
13
 * Class ProcessFactory
14
 * @package Paraunit\Process
15
 */
16
class ProcessFactory
17
{
18
    /** @var CommandLine */
19
    private $cliCommand;
20
21
    /** @var string[] */
22
    private $baseCommandLine;
23
24
    /** @var string[] */
25
    private $environmentVariables;
26
27
    /**
28
     * ProcessFactory constructor.
29
     * @param CommandLine $cliCommand
30
     * @param PHPUnitConfig $phpunitConfig
31
     * @param TempFilenameFactory $tempFilenameFactory
32
     */
33
    public function __construct(
34
        CommandLine $cliCommand,
35
        PHPUnitConfig $phpunitConfig,
36
        TempFilenameFactory $tempFilenameFactory
37
    ) {
38
        $this->cliCommand = $cliCommand;
39
        $this->baseCommandLine = array_merge($this->cliCommand->getExecutable(), $this->cliCommand->getOptions($phpunitConfig));
0 ignored issues
show
Documentation Bug introduced by
It seems like array_merge($this->cliCo...ptions($phpunitConfig)) of type array is incompatible with the declared type array<integer,string> of property $baseCommandLine.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
40
        $this->environmentVariables = [
0 ignored issues
show
Documentation Bug introduced by
It seems like array(\Paraunit\Configur...ctory->getPathForLog()) of type array<string|integer,string> is incompatible with the declared type array<integer,string> of property $environmentVariables.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
41
            EnvVariables::LOG_DIR => $tempFilenameFactory->getPathForLog(),
42
        ];
43
    }
44
45
    public function create(string $testFilePath): AbstractParaunitProcess
46
    {
47
        $process = new Process(
48
            array_merge($this->baseCommandLine, [$testFilePath], $this->cliCommand->getSpecificOptions($testFilePath)),
49
            null,
50
            $this->environmentVariables
51
        );
52
        $process->inheritEnvironmentVariables();
53
54
        return new SymfonyProcessWrapper($process, $testFilePath);
55
    }
56
}
57