Completed
Pull Request — master (#102)
by Alessandro
07:08
created

DeprecationParser::handleLogItem()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 6
nc 3
nop 2
crap 3
1
<?php
2
3
namespace Paraunit\Parser;
4
5
use Paraunit\Parser\JSON\ParserChainElementInterface;
6
use Paraunit\Process\AbstractParaunitProcess;
7
use Paraunit\TestResult\Interfaces\TestResultContainerInterface;
8
use Paraunit\TestResult\Interfaces\TestResultHandlerInterface;
9
use Paraunit\TestResult\TestResultWithMessage;
10
11
class DeprecationParser implements ParserChainElementInterface
12
{
13
    /** @var TestResultHandlerInterface */
14
    private $testResultContainer;
15
16
    /**
17
     * DeprecationParser constructor.
18
     * @param TestResultContainerInterface $testResultContainer
19
     */
20 32
    public function __construct(TestResultContainerInterface $testResultContainer)
21
    {
22 32
        $this->testResultContainer = $testResultContainer;
0 ignored issues
show
Documentation Bug introduced by
It seems like $testResultContainer of type object<Paraunit\TestResu...sultContainerInterface> is incompatible with the declared type object<Paraunit\TestResu...ResultHandlerInterface> of property $testResultContainer.

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...
23
    }
24
25 29
    public function handleLogItem(AbstractParaunitProcess $process, \stdClass $logItem)
26
    {
27 29
        if ($process->getExitCode() === 0) {
28 19
            return;
29
        }
30
31 12
        if (strpos($process->getOutput(), 'deprecation') !== false) {
32 3
            $testResult = $this->createTestResult($process);
33 3
            $this->testResultContainer->handleTestResult($process, $testResult);
34
        }
35
    }
36
37 3
    private function createTestResult(AbstractParaunitProcess $process): TestResultWithMessage
38
    {
39 3
        return new TestResultWithMessage(
40 3
            $process->getTestClassName() ?? $process->getFilename(),
41 3
            $process->getOutput()
42
        );
43
    }
44
}
45