CommandLineWithCoverage::getSpecificOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Paraunit\Process;
6
7
use Paraunit\Configuration\PHPDbgBinFile;
8
use Paraunit\Configuration\PHPUnitBinFile;
9
use Paraunit\Configuration\PHPUnitConfig;
10
use Paraunit\Configuration\TempFilenameFactory;
11
12
/**
13
 * Class CommandLineWithCoverage
14
 * @package Paraunit\Process
15
 */
16
class CommandLineWithCoverage extends CommandLine
17
{
18
    /** @var PHPDbgBinFile */
19
    private $phpDbgBinFile;
20
21
    /** @var TempFilenameFactory */
22
    private $filenameFactory;
23
24
    /**
25
     * TestCliCommand constructor.
26
     * @param PHPUnitBinFile $phpUnitBin
27
     * @param PHPDbgBinFile $dbgBinFile
28
     * @param TempFilenameFactory $filenameFactory
29
     */
30 11
    public function __construct(
31
        PHPUnitBinFile $phpUnitBin,
32
        PHPDbgBinFile $dbgBinFile,
33
        TempFilenameFactory $filenameFactory
34
    ) {
35 11
        parent::__construct($phpUnitBin);
36
37 11
        $this->phpDbgBinFile = $dbgBinFile;
38 11
        $this->filenameFactory = $filenameFactory;
39
    }
40
41
    /**
42
     * @return string[]
43
     * @throws \RuntimeException
44
     */
45 8
    public function getExecutable(): array
46
    {
47 8
        if ($this->phpDbgBinFile->isAvailable()) {
48 7
            return [$this->phpDbgBinFile->getPhpDbgBin()];
49
        }
50
51 1
        return parent::getExecutable();
52
    }
53
54
    /**
55
     * @param PHPUnitConfig $config
56
     * @return array
57
     * @throws \RuntimeException
58
     */
59 8
    public function getOptions(PHPUnitConfig $config): array
60
    {
61 8
        if (! $this->phpDbgBinFile->isAvailable()) {
62 1
            return parent::getOptions($config);
63
        }
64
65 7
        return array_merge(
66
            [
67 7
                '-qrr',
68 7
                $this->phpUnitBin->getPhpUnitBin(),
69
            ],
70 7
            parent::getOptions($config)
71
        );
72
    }
73
74 6
    public function getSpecificOptions(string $testFilename): array
75
    {
76 6
        $options = parent::getSpecificOptions($testFilename);
77 6
        $options[] = '--coverage-php=' . $this->filenameFactory->getFilenameForCoverage(md5($testFilename));
78
79 6
        return $options;
80
    }
81
}
82