StrictCoverageProcessor::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace PhpGitHooks\Module\PhpUnit\Infrastructure\Tool;
4
5
use PhpGitHooks\Infrastructure\Tool\ToolPathFinder;
6
use PhpGitHooks\Module\PhpUnit\Model\StrictCoverageProcessorInterface;
7
use Symfony\Component\Process\Process;
8
9
class StrictCoverageProcessor implements StrictCoverageProcessorInterface
10
{
11
    /**
12
     * @var ToolPathFinder
13
     */
14
    private $toolPathFinder;
15
16
    /**
17
     * StrictCoverageProcessor constructor.
18
     *
19
     * @param ToolPathFinder $toolPathFinder
20
     */
21
    public function __construct(ToolPathFinder $toolPathFinder)
22
    {
23
        $this->toolPathFinder = $toolPathFinder;
24
    }
25
26
    /**
27
     * @return float
28
     */
29
    public function process()
30
    {
31
        $tool = $this->toolPathFinder->find('phpunit');
32
        $command = 'php '.$tool.' --coverage-text|grep Classes| tr -s \' \' |cut -d " " -f 3|cut -d "%" -f 1';
33
34
        $process = new Process($command);
0 ignored issues
show
Documentation introduced by
$command is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
        $process->run();
36
37
        return (float) $process->getOutput();
38
    }
39
}
40