Completed
Push — master ( 83aeed...e335a8 )
by Alessandro
05:08
created

FilesRecapPrinter::printFileRecap()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 27
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
ccs 21
cts 21
cp 1
rs 8.5806
cc 4
eloc 17
nc 4
nop 1
crap 4
1
<?php
2
3
namespace Paraunit\Printer;
4
5
use Paraunit\Lifecycle\EngineEvent;
6
use Paraunit\TestResult\TestResultContainer;
7
8
/**
9
 * Class FilesRecapPrinter
10
 * @package Paraunit\Printer
11
 */
12
class FilesRecapPrinter extends AbstractFinalPrinter
13
{
14
    /**
15
     * @param EngineEvent $engineEvent
16
     */
17 10 View Code Duplication
    public function onEngineEnd(EngineEvent $engineEvent)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    {
19 10
        $this->output = $engineEvent->getOutputInterface();
20
        /** @var \DateInterval $elapsedTime */
21
22 10
        foreach ($this->logParser->getParsersForPrinting() as $parser) {
23 10
            if ($parser instanceof TestResultContainer) {
24 10
                $this->printFileRecap($parser);
25 10
            }
26 10
        }
27 10
    }
28
29
    /**
30
     * @param TestResultContainer $testResultContainer
31
     */
32 10
    private function printFileRecap(TestResultContainer $testResultContainer)
33
    {
34 10
        if ( ! $testResultContainer->getTestResultFormat()->shouldPrintFilesRecap()) {
35 10
            return;
36
        }
37
38 10
        $filenames = $testResultContainer->getFileNames();
39
40 10
        if (count($filenames)) {
41 9
            $tag = $testResultContainer->getTestResultFormat()->getTag();
42 9
            $title = $testResultContainer->getTestResultFormat()->getTitle();
43 9
            $this->output->writeln('');
44 9
            $this->output->writeln(
45 9
                sprintf(
46 9
                    '<%s>%d files with %s:</%s>',
47 9
                    $tag,
48 9
                    count($filenames),
49 9
                    strtoupper($title),
50
                    $tag
51 9
                )
52 9
            );
53
54 9
            foreach ($filenames as $fileName) {
55 9
                $this->output->writeln(sprintf(' <%s>%s</%s>', $tag, $fileName, $tag));
56 9
            }
57 9
        }
58 10
    }
59
}
60