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

Text   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A output() 0 17 4
A generateOutputLine() 0 11 3
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