Passed
Push — master ( 146be5...1e12ef )
by ANTHONIUS
06:12
created

Console::coverageInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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 <[email protected]>
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\Console;
15
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
use Symfony\Component\Console\Style\StyleInterface;
19
use Symfony\Component\Console\Style\SymfonyStyle;
20
21
class Console implements ConsoleIO
22
{
23
    /**
24
     * @var StyleInterface
25
     */
26
    private $style;
27
28
    /**
29
     * Console constructor.
30
     *
31
     * @todo Change this to only accept style interface
32
     *
33
     * @param InputInterface|StyleInterface $style
34
     * @param OutputInterface|null          $output
35
     */
36 6
    public function __construct($style, OutputInterface $output = null)
37
    {
38 6
        if ($style instanceof InputInterface) {
39 2
            $style = new SymfonyStyle($style, $output);
0 ignored issues
show
Bug introduced by
It seems like $output can also be of type null; however, parameter $output of Symfony\Component\Consol...onyStyle::__construct() does only seem to accept Symfony\Component\Console\Output\OutputInterface, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
            $style = new SymfonyStyle($style, /** @scrutinizer ignore-type */ $output);
Loading history...
40
        }
41 6
        $this->style = $style;
42
    }
43
44 2
    public function coverageSection(string $section)
45
    {
46 2
        $this->style->section('coverage: '.$section);
47
    }
48
49 2
    public function coverageInfo(string $message)
50
    {
51 2
        $this->style->text($message);
52
    }
53
54 1
    public function coverageError(string $message)
55
    {
56 1
        $this->style->error($message);
57
    }
58
}
59