1 | <?php |
||
17 | class ProcessPrinter implements EventSubscriberInterface |
||
18 | { |
||
19 | const MAX_CHAR_LENGTH = 80; |
||
20 | const COUNTER_CHAR_LENGTH = 5; |
||
21 | |||
22 | /** @var SingleResultFormatter */ |
||
23 | private $singleResultFormatter; |
||
24 | |||
25 | /** @var OutputInterface */ |
||
26 | private $output; |
||
27 | |||
28 | /** @var int */ |
||
29 | private $counter; |
||
30 | |||
31 | /** @var int */ |
||
32 | private $singleRowCounter; |
||
33 | |||
34 | /** |
||
35 | * ProcessPrinter constructor. |
||
36 | * @param SingleResultFormatter $singleResultFormatter |
||
37 | * @param OutputInterface $output |
||
38 | */ |
||
39 | 44 | public function __construct(SingleResultFormatter $singleResultFormatter, OutputInterface $output) |
|
46 | |||
47 | 64 | public static function getSubscribedEvents(): array |
|
48 | { |
||
49 | return [ |
||
50 | 64 | ProcessEvent::PROCESS_PARSING_COMPLETED => 'onProcessCompleted', |
|
51 | 64 | ProcessEvent::PROCESS_TO_BE_RETRIED => 'onProcessCompleted', |
|
52 | 64 | EngineEvent::END => ['onEngineEnd', 400], |
|
53 | ]; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @param ProcessEvent $processEvent |
||
58 | * @throws \BadMethodCallException |
||
59 | */ |
||
60 | 38 | public function onProcessCompleted(ProcessEvent $processEvent) |
|
68 | |||
69 | 21 | public function onEngineEnd() |
|
70 | { |
||
71 | 21 | while (! $this->isRowFull()) { |
|
72 | 21 | $this->output->write(' '); |
|
73 | 21 | ++$this->singleRowCounter; |
|
74 | } |
||
75 | |||
76 | 21 | $this->printCounter(); |
|
77 | } |
||
78 | |||
79 | /** |
||
80 | * @param PrintableTestResultInterface $testResult |
||
81 | */ |
||
82 | 38 | private function printFormattedWithCounter(PrintableTestResultInterface $testResult) |
|
95 | |||
96 | 27 | private function printCounter() |
|
101 | |||
102 | 42 | private function isRowFull(): bool |
|
103 | { |
||
106 | } |
||
107 |