Completed
Push — master ( 9dfaca...8ef6fd )
by Alessandro
14s
created

DebugPrinter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 4
dl 0
loc 44
ccs 19
cts 19
cp 1
rs 10

5 Methods

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