Completed
Pull Request — master (#59)
by Alessandro
06:35
created

TestWithCoverageCommandLine::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Paraunit\Process;
4
5
use Paraunit\Configuration\PHPDbgBinFile;
6
use Paraunit\Configuration\PHPUnitBinFile;
7
use Paraunit\Configuration\PHPUnitConfig;
8
use Paraunit\Configuration\TempFilenameFactory;
9
10
class TestWithCoverageCommandLine extends TestCommandLine implements CliCommandInterface
11
{
12
    /** @var PHPDbgBinFile */
13
    private $phpDbgBinFile;
14
15
    /**
16
     * TestCliCommand constructor.
17
     * @param PHPUnitBinFile $phpUnitBin
18
     * @param PHPDbgBinFile $dbgBinFile
19
     * @param TempFilenameFactory $filenameFactory
20
     */
21 4
    public function __construct(PHPUnitBinFile $phpUnitBin, PHPDbgBinFile $dbgBinFile, TempFilenameFactory $filenameFactory)
22
    {
23 4
        parent::__construct($phpUnitBin, $filenameFactory);
24
25 4
        $this->phpDbgBinFile = $dbgBinFile;
26 4
    }
27
28
    /**
29
     * @return string
30
     */
31 2
    public function getExecutable()
32
    {
33 2
        if ($this->phpDbgBinFile->isAvailable()) {
34 1
            return $this->phpDbgBinFile->getPhpDbgBin();
35
        }
36
37 1
        return parent::getExecutable();
38
    }
39
40
    /**
41
     * @param PHPUnitConfig $config
42
     * @param string $uniqueId
43
     * @return string
44
     */
45 2
    public function getOptions(PHPUnitConfig $config, $uniqueId)
46
    {
47 2
        $options = '';
48 2
        if ($this->phpDbgBinFile->isAvailable()) {
49
            $options .= '-qrr '
50 1
                . parent::getExecutable() . ' ';
1 ignored issue
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getExecutable() instead of getOptions()). Are you sure this is correct? If so, you might want to change this to $this->getExecutable().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
51 1
        }
52
53
        return $options
54 2
            . parent::getOptions($config, $uniqueId)
55 2
            . ' --coverage-php '
56 2
            . $this->filenameFactory->getFilenameForCoverage($uniqueId);
57
    }
58
}
59