Passed
Push — master ( cc91a3...057c43 )
by Christian
02:20
created

ConsoleOutput   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 42
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createProgressBar() 0 7 1
A writeln() 0 3 1
A debug() 0 4 2
A write() 0 3 1
1
<?php
2
3
namespace Scheb\Tombstone\Analyzer\Cli;
4
5
use Symfony\Component\Console\Helper\ProgressBar;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
class ConsoleOutput
9
{
10
    /**
11
     * @var OutputInterface
12
     */
13
    private $output;
14
15
    /**
16
     * @var bool
17
     */
18
    private $isDebug;
19
20
    public function __construct(OutputInterface $output)
21
    {
22
        $this->output = $output;
23
        $this->isDebug = $output->isDebug();
24
    }
25
26
    public function write(string $string): void
27
    {
28
        $this->output->write($string);
29
    }
30
31
    public function writeln(?string $string = null): void
32
    {
33
        $this->output->writeln($string ?? '');
34
    }
35
36
    public function debug($string): void
37
    {
38
        if ($this->isDebug) {
39
            $this->writeln($string);
40
        }
41
    }
42
43
    public function createProgressBar(int $width): ProgressBar
44
    {
45
        $progress = new ProgressBar($this->output, $width);
46
        $progress->setBarWidth(50);
47
        $progress->display();
48
49
        return $progress;
50
    }
51
}
52