Completed
Push — master ( 333d3e...c7e85e )
by Luis
03:07
created

UpdaterDisplay::noUpdateApplied()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
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 Exception;
11
use Symfony\Component\Console\Output\OutputInterface;
12
use Symfony\Component\Console\Output\StreamOutput;
13
14
class UpdaterDisplay
15
{
16
    /** @var OutputInterface */
17
    private $output;
18
19 27
    public function __construct(OutputInterface $output = null)
20
    {
21 27
        $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

21
        $this->output = $output ?? new StreamOutput(/** @scrutinizer ignore-type */ fopen('php://memory', 'w', false));
Loading history...
22 27
    }
23
24 6
    public function rollbackMessage(bool $result): void
25
    {
26 6
        if ($result) {
27 3
            $this->output->writeln('<info>phUML has been rolled back to prior version.</info>');
28
        } else {
29 3
            $this->output->writeln('<error>Rollback failed for unknown reasons.</error>');
30
        }
31 6
    }
32
33 3
    public function currentLocalVersion(string $version): void
34
    {
35 3
        $this->output->writeln(sprintf(
36 3
            'Your current local build version is: <options=bold>%s</options=bold>',
37 3
            $version
38
        ));
39 3
    }
40
41 3
    public function newVersion(string $newVersion): void
42
    {
43 3
        $this->output->writeln(sprintf(
44 3
            'The current stable build available remotely is: <options=bold>%s</options=bold>',
45 3
            $newVersion
46
        ));
47 3
    }
48
49 3
    public function noUpdatesAvailable(): void
50
    {
51 3
        $this->output->writeln('There are no stable builds available.');
52 3
    }
53
54 3
    public function alreadyUpToDate(): void
55
    {
56 3
        $this->output->writeln('You have the current stable build installed.');
57 3
    }
58
59 3
    public function updateApplied(string $oldVersion, string $newVersion): void
60
    {
61 3
        $this->output->writeln('<info>phUML has been updated.</info>');
62 3
        $this->output->writeln(sprintf(
63 3
            '<info>Current version is:</info> <options=bold>%s</options=bold>.',
64 3
            $newVersion
65
        ));
66 3
        $this->output->writeln(sprintf(
67 3
            '<info>Previous version was:</info> <options=bold>%s</options=bold>.',
68 3
            $oldVersion
69
        ));
70 3
    }
71
72 3
    public function noUpdateApplied(string $currentVersion): void
73
    {
74 3
        $this->output->writeln('<info>phUML is currently up to date.</info>');
75 3
        $this->output->writeln(sprintf(
76 3
            '<info>Current version is:</info> <options=bold>%s</options=bold>.',
77 3
            $currentVersion
78
        ));
79 3
    }
80
81 3
    public function error(Exception $exception): void
82
    {
83 3
        $this->output->writeln(sprintf('Error: <comment>%s</comment>', $exception->getMessage()));
84 3
    }
85
}
86