Completed
Push — master ( 6b1baa...9e395d )
by ANTHONIUS
16s queued 11s
created

Console   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 34
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A coverageError() 0 3 1
A coverageInfo() 0 3 1
A coverageSection() 0 3 1
A __construct() 0 6 2
1
<?php
2
3
4
namespace Doyo\Bridge\CodeCoverage\Console;
5
6
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Style\StyleInterface;
10
use Symfony\Component\Console\Style\SymfonyStyle;
11
12
class Console implements ConsoleIO
13
{
14
    /**
15
     * @var StyleInterface
16
     */
17
    private $style;
18
19
    /**
20
     * Console constructor.
21
     * @todo Change this to only accept style interface
22
     * @param InputInterface|StyleInterface $style
23
     * @param OutputInterface|null $output
24
     */
25 6
    public function __construct($style, OutputInterface $output = null)
26
    {
27 6
        if($style instanceof InputInterface){
28 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

28
            $style = new SymfonyStyle($style, /** @scrutinizer ignore-type */ $output);
Loading history...
29
        }
30 6
        $this->style = $style;
31
    }
32
33 2
    public function coverageSection(string $section)
34
    {
35 2
        $this->style->section('coverage: '.$section);
36
    }
37
38 2
    public function coverageInfo(string $message)
39
    {
40 2
        $this->style->text($message);
41
    }
42
43 1
    public function coverageError(string $message)
44
    {
45 1
        $this->style->error($message);
46
    }
47
}
48