Completed
Push — master ( 9d1ab7...13f027 )
by Luis
04:13 queued 02:19
created

ProgressDisplay::display()   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
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Console;
9
10
use PhUml\Generators\ProcessorProgressDisplay;
11
use PhUml\Processors\Processor;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use Symfony\Component\Console\Output\StreamOutput;
14
15
/**
16
 * It provides visual feedback to the use about the progress of the current command
17
 *
18
 * @see ProcessorProgressDisplay for more details about the things that are reported by this display
19
 */
20
class ProgressDisplay implements ProcessorProgressDisplay
21
{
22
    /** @var OutputInterface */
23
    private $output;
24
25 45
    public function __construct(OutputInterface $output = null)
26
    {
27 45
        $this->output = $output ?? new StreamOutput(fopen('php://memory', 'w', false));
0 ignored issues
show
Bug introduced by
It seems like fopen('php://memory', 'w', false) can also be of type false; however, parameter $stream of Symfony\Component\Consol...amOutput::__construct() does only seem to accept resource, 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

27
        $this->output = $output ?? new StreamOutput(/** @scrutinizer ignore-type */ fopen('php://memory', 'w', false));
Loading history...
28 45
    }
29
30 21
    public function start(): void
31
    {
32 21
        $this->display('Running... (This may take some time)');
33 21
    }
34
35 21
    public function runningParser(): void
36
    {
37 21
        $this->display('Parsing codebase structure');
38 21
    }
39
40 21
    public function runningProcessor(Processor $processor): void
41
    {
42 21
        $this->display("Running '{$processor->name()}' processor");
43 21
    }
44
45 21
    public function savingResult(): void
46
    {
47 21
        $this->display('Writing generated data to disk');
48 21
    }
49
50 21
    private function display(string $message)
51
    {
52 21
        $this->output->writeln("<info>[|]</info> $message");
53 21
    }
54
}
55