Completed
Push — master ( 3f2b6b...56185f )
by Scott
06:20
created

Text::output()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
nc 4
nop 3
dl 0
loc 17
rs 9.2
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($coverage, $percent, $minimumPercent)
9
    {
10
11
        printf("%.2f%% Covered\n", $percent);
12
        if ($percent > $minimumPercent) {
13
            return;
14
        }
15
        $output = '';
16
        foreach ($coverage as $filename => $lines) {
17
            $output .= "\n\n'$filename' has no coverage for the following lines:\n";
18
            foreach ($lines as $line => $message) {
19
                $output .= $this->generateOutputLine($line, $message);
20
            }
21
        }
22
23
        echo trim($output);
24
    }
25
26
    private function generateOutputLine($line, $message)
27
    {
28
        $output = "Line $line:\n";
29
        if (!empty($message)) {
30
            foreach ((array) $message as $part) {
31
                $output .= "\t$part\n";
32
            }
33
        }
34
35
        return $output . "\n";
36
    }
37
}
38