Text::getOutputType()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the doyo/code-coverage project.
5
 *
6
 * (c) Anthonius Munthi <https://itstoni.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Doyo\Bridge\CodeCoverage\Report;
15
16
use Doyo\Bridge\CodeCoverage\Console\ConsoleIO;
17
use Doyo\Bridge\CodeCoverage\ProcessorInterface;
18
19
class Text extends AbstractReportProcessor
20
{
21
    protected $defaultOptions = [
22
        'target' => 'console',
23
    ];
24
25 6
    public function getProcessorClass(): string
26
    {
27 6
        return \SebastianBergmann\CodeCoverage\Report\Text::class;
28
    }
29
30 6
    public function getOutputType(): string
31
    {
32 6
        return 'console' !== $this->getTarget() ? static::OUTPUT_FILE : static::OUTPUT_CONSOLE;
33
    }
34
35 2
    public function getType(): string
36
    {
37 2
        return 'text';
38
    }
39
40 3
    public function process(ProcessorInterface $processor, ConsoleIO $consoleIO)
41
    {
42 3
        $reportProcessor = $this->processor;
43 3
        $coverage        = $processor->getCodeCoverage();
44 3
        $target          = $this->target;
45
46 3
        $output = $reportProcessor->process($coverage);
47 3
        if ('console' === $target) {
48 2
            $consoleIO->coverageInfo($output);
49
        } else {
50 1
            file_put_contents($target, $output);
51
        }
52
    }
53
}
54