Completed
Pull Request — master (#86)
by Alessandro
04:41
created

ProcessFactory::setPHPUnitConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Paraunit\Process;
4
5
use Paraunit\Configuration\PHPUnitConfig;
6
7
/**
8
 * Class ProcessFactory
9
 * @package Paraunit\Process
10
 */
11
class ProcessFactory
12
{
13
    /** @var  CliCommandInterface */
14
    private $cliCommand;
15
16
    /** @var  PHPUnitConfig */
17
    private $phpunitConfig;
18
19
    /**
20
     * ProcessFactory constructor.
21
     * @param CliCommandInterface $cliCommand
22
     * @param PHPUnitConfig $phpunitConfig
23
     */
24 12
    public function __construct(CliCommandInterface $cliCommand, PHPUnitConfig $phpunitConfig)
25
    {
26 12
        $this->cliCommand = $cliCommand;
27 12
        $this->phpunitConfig = $phpunitConfig;
28 12
    }
29
30
    /**
31
     * @param $testFilePath
32
     * @return SymfonyProcessWrapper
33
     * @throws \Exception
34
     */
35 12
    public function createProcess($testFilePath)
36
    {
37 12
        $uniqueId = $this->createUniqueId($testFilePath);
38 12
        $command = $this->createCommandLine($testFilePath, $uniqueId);
39
40 12
        return new SymfonyProcessWrapper($command, $uniqueId);
41
    }
42
43
    /**
44
     * @param string $testFilePath
45
     * @param string $uniqueId
46
     * @return string
47
     */
48 12
    private function createCommandLine($testFilePath, $uniqueId)
49
    {
50 12
        return $this->cliCommand->getExecutable()
51 12
            . ' ' . $this->cliCommand->getOptions($this->phpunitConfig, $uniqueId)
52 12
            . ' ' . $testFilePath;
53
    }
54
55
    /**
56
     * @param string $testFilePath
57
     * @return string
58
     */
59 12
    private function createUniqueId($testFilePath)
60
    {
61 12
        return md5($testFilePath);
62
    }
63
}
64