Completed
Push — master ( 84f230...078d96 )
by Alessandro
12s
created

DeprecationParser::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 2
cts 2
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Paraunit\Parser;
4
5
use Paraunit\Lifecycle\ProcessEvent;
6
use Paraunit\Process\AbstractParaunitProcess;
7
use Paraunit\TestResult\Interfaces\TestResultContainerInterface;
8
use Paraunit\TestResult\Interfaces\TestResultHandlerInterface;
9
use Paraunit\TestResult\TestResultWithMessage;
10
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
11
12
class DeprecationParser implements EventSubscriberInterface
13
{
14
    /** @var TestResultHandlerInterface */
15
    private $testResultContainer;
16
17
    /**
18
     * DeprecationParser constructor.
19
     * @param TestResultContainerInterface $testResultContainer
20
     */
21 29
    public function __construct(TestResultContainerInterface $testResultContainer)
22
    {
23 29
        $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...
24
    }
25
26 59
    public static function getSubscribedEvents(): array
27
    {
28
        return [
29 59
            ProcessEvent::PROCESS_PARSING_COMPLETED => 'handleDeprecations',
30
        ];
31
    }
32
33 29
    public function handleDeprecations(ProcessEvent $event)
34
    {
35 29
        $process = $event->getProcess();
36
37 29
        if ($process->getExitCode() === 0) {
38 19
            return;
39
        }
40
41 12
        if (strpos($process->getOutput(), 'deprecation') !== false) {
42 3
            $testResult = $this->createTestResult($process);
43 3
            $this->testResultContainer->handleTestResult($process, $testResult);
44
        }
45
    }
46
47 3
    private function createTestResult(AbstractParaunitProcess $process): TestResultWithMessage
48
    {
49 3
        return new TestResultWithMessage(
50 3
            $process->getTestClassName() ?? $process->getFilename(),
51 3
            $process->getOutput()
52
        );
53
    }
54
}
55