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

DeprecationParser   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 34
ccs 12
cts 12
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handleLogItem() 0 11 3
A createTestResult() 0 7 1
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