Completed
Push — master ( 74d784...d308b8 )
by Alessandro
06:27
created

FilesRecapPrinter::printFileRecap()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 27
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 4.0016

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 27
ccs 20
cts 21
cp 0.9524
rs 8.5806
cc 4
eloc 17
nc 4
nop 2
crap 4.0016
1
<?php
2
3
namespace Paraunit\Printer;
4
5
use Paraunit\Lifecycle\EngineEvent;
6
use Paraunit\TestResult\Interfaces\TestFilenameBearerInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Class FilesRecapPrinter
11
 * @package Paraunit\Printer
12
 */
13
class FilesRecapPrinter extends AbstractFinalPrinter
14
{
15
    /**
16
     * @param EngineEvent $engineEvent
17
     */
18 11
    public function onEngineEnd(EngineEvent $engineEvent)
19
    {
20 11
        $output = $engineEvent->getOutputInterface();
21
22 11
        foreach ($this->testResultList->getTestResultContainers() as $parser) {
23 11
            $this->printFileRecap($parser, $output);
24 11
        }
25 11
    }
26
27
    /**
28
     * @param TestFilenameBearerInterface $testResultContainer
29
     * @param OutputInterface $output
30
     */
31 11
    private function printFileRecap(TestFilenameBearerInterface $testResultContainer, OutputInterface $output)
32
    {
33 11
        if (! $testResultContainer->getTestResultFormat()->shouldPrintFilesRecap()) {
34
            return;
35
        }
36
37 11
        $filenames = $testResultContainer->getFileNames();
38
39 11
        if (count($filenames)) {
40 10
            $tag = $testResultContainer->getTestResultFormat()->getTag();
41 10
            $title = $testResultContainer->getTestResultFormat()->getTitle();
42 10
            $output->writeln('');
43 10
            $output->writeln(
44 10
                sprintf(
45 10
                    '<%s>%d files with %s:</%s>',
46 10
                    $tag,
47 10
                    count($filenames),
48 10
                    strtoupper($title),
49
                    $tag
50 10
                )
51 10
            );
52
53 10
            foreach ($filenames as $fileName) {
54 10
                $output->writeln(sprintf(' <%s>%s</%s>', $tag, $fileName, $tag));
55 10
            }
56 10
        }
57 11
    }
58
}
59