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