Passed
Branch master (9c9e82)
by ANTHONIUS
01:35
created

Text::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 2
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Doyo\Bridge\CodeCoverage\Report;
4
5
use Doyo\Bridge\CodeCoverage\Console\ConsoleIO;
6
use Doyo\Bridge\CodeCoverage\ProcessorInterface;
7
8
class Text extends AbstractReportProcessor
9
{
10
    protected $defaultOptions = [
11
        'target' => 'console'
12
    ];
13
14 4
    public function getProcessorClass(): string
15
    {
16 4
        return \SebastianBergmann\CodeCoverage\Report\Text::class;
17
    }
18
19 4
    public function getOutputType(): string
20
    {
21
22 4
        return $this->getTarget() !== 'console' ? static::OUTPUT_FILE:static::OUTPUT_CONSOLE;
23
    }
24
25 1
    public function getType(): string
26
    {
27 1
        return 'text';
28
    }
29
30 2
    public function process(ProcessorInterface $processor, ConsoleIO $consoleIO)
31
    {
32 2
        $reportProcessor = $this->processor;
33 2
        $coverage = $processor->getCodeCoverage();
34 2
        $target = $this->target;
35
36 2
        $output = $reportProcessor->process($coverage);
37 2
        if('console' === $target){
38 1
            $consoleIO->coverageInfo($output);
39
        }else{
40 1
            file_put_contents($target, $output);
41
        }
42
    }
43
}
44