DebugPrinter::onProcessTerminated()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Paraunit\Printer;
6
7
use Paraunit\Lifecycle\ProcessEvent;
8
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
9
10
/**
11
 * Class DebugPrinter
12
 * @package Paraunit\Printer
13
 */
14
class DebugPrinter extends AbstractPrinter implements EventSubscriberInterface
15
{
16 4
    public static function getSubscribedEvents(): array
17
    {
18
        return [
19 4
            ProcessEvent::PROCESS_STARTED => 'onProcessStarted',
20
            ProcessEvent::PROCESS_TERMINATED => 'onProcessTerminated',
21
            ProcessEvent::PROCESS_PARSING_COMPLETED => ['onProcessParsingCompleted', 1],
22
            ProcessEvent::PROCESS_TO_BE_RETRIED => 'onProcessToBeRetried',
23
        ];
24
    }
25
26 2
    public function onProcessStarted(ProcessEvent $event)
27
    {
28 2
        $process = $event->getProcess();
29
30 2
        $this->getOutput()->writeln('PROCESS STARTED: ' . $process->getFilename());
31 2
        $this->getOutput()->writeln($process->getCommandLine());
32 2
        $this->getOutput()->writeln('');
33
    }
34
35 2
    public function onProcessTerminated(ProcessEvent $event)
36
    {
37 2
        $process = $event->getProcess();
38
39 2
        $this->getOutput()->writeln('');
40 2
        $this->getOutput()->writeln('PROCESS TERMINATED: ' . $process->getFilename());
41 2
        $this->getOutput()->writeln(' - with class name: ' . $process->getTestClassName() ?? 'N/A');
42 2
        $this->getOutput()->writeln('');
43
    }
44
45 2
    public function onProcessParsingCompleted()
46
    {
47 2
        $this->getOutput()->write('PROCESS PARSING COMPLETED -- RESULTS: ');
48
    }
49
50 2
    public function onProcessToBeRetried(ProcessEvent $event)
51
    {
52 2
        $process = $event->getProcess();
53
54 2
        $this->getOutput()->writeln('');
55 2
        $this->getOutput()->writeln('PROCESS TO BE RETRIED: ' . $process->getFilename());
56
    }
57
}
58