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

FilesRecapPrinter::onEngineEnd()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 11
loc 11
ccs 8
cts 8
cp 1
rs 9.4285
cc 3
eloc 5
nc 3
nop 1
crap 3
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