Text::output()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 3
dl 0
loc 14
rs 10
c 0
b 0
f 0
1
<?php
2
namespace exussum12\CoverageChecker\Outputs;
3
4
use exussum12\CoverageChecker\Output;
5
6
class Text implements Output
7
{
8
    public function output(array $coverage, float $percent, float $minimumPercent)
9
    {
10
11
        printf("%.2f%% Covered\n", $percent);
12
13
        $output = '';
14
        foreach ($coverage as $filename => $lines) {
15
            $output .= "\n\n'$filename' has no coverage for the following lines:\n";
16
            foreach ($lines as $line => $message) {
17
                $output .= $this->generateOutputLine($line, $message);
18
            }
19
        }
20
21
        echo trim($output) . "\n";
22
    }
23
24
    private function generateOutputLine($line, $message)
25
    {
26
        $output = "Line $line:\n";
27
        if (!empty($message)) {
28
            foreach ($message as $part) {
29
                $output .= "\t$part\n";
30
            }
31
        }
32
33
        return $output . "\n";
34
    }
35
}
36