1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the box project. |
7
|
|
|
* |
8
|
|
|
* (c) Kevin Herrera <[email protected]> |
9
|
|
|
* Théo Fidry <[email protected]> |
10
|
|
|
* |
11
|
|
|
* This source file is subject to the MIT license that is bundled |
12
|
|
|
* with this source code in the file LICENSE. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace KevinGH\Box\Logger; |
16
|
|
|
|
17
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
18
|
|
|
use Throwable; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @private |
22
|
|
|
* @final |
23
|
|
|
*/ |
24
|
|
|
class UpdateConsoleLogger |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var SymfonyStyle |
28
|
|
|
*/ |
29
|
|
|
private $io; |
30
|
|
|
|
31
|
|
|
public function __construct(SymfonyStyle $io) |
32
|
|
|
{ |
33
|
|
|
$this->io = $io; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function startUpdating(): void |
37
|
|
|
{ |
38
|
|
|
$this->io->writeln('Updating...'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function updateSuccess(string $newVersion, string $oldVersion): void |
42
|
|
|
{ |
43
|
|
|
$this->io->success('PHP-Scoper has been updated.'); |
44
|
|
|
$this->io->writeln(sprintf( |
45
|
|
|
'Current version is: <comment>%s</comment>.', |
46
|
|
|
$newVersion |
47
|
|
|
)); |
48
|
|
|
$this->io->writeln(sprintf( |
49
|
|
|
'Previous version was: <comment>%s</comment>.', |
50
|
|
|
$oldVersion |
51
|
|
|
)); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function updateNotNeeded(string $oldVersion): void |
55
|
|
|
{ |
56
|
|
|
$this->io->writeln('PHP-Scoper is currently up to date.'); |
57
|
|
|
$this->io->writeln(sprintf( |
58
|
|
|
'Current version is: <comment>%s</comment>.', |
59
|
|
|
$oldVersion |
60
|
|
|
)); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function error(Throwable $e): void |
|
|
|
|
64
|
|
|
{ |
65
|
|
|
$this->io->error('Unexpected error. If updating, your original phar is untouched.'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function rollbackSuccess(): void |
69
|
|
|
{ |
70
|
|
|
$this->io->success('PHP-Scoper has been rolled back to prior version.'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function rollbackFail(): void |
74
|
|
|
{ |
75
|
|
|
$this->io->error('Rollback failed for reasons unknown.'); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function printLocalVersion(string $version): void |
79
|
|
|
{ |
80
|
|
|
$this->io->writeln(sprintf( |
81
|
|
|
'Your current local version is: <comment>%s</comment>', |
82
|
|
|
$version |
83
|
|
|
)); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function printRemoteVersion(string $stability, string $version): void |
87
|
|
|
{ |
88
|
|
|
$this->io->writeln(sprintf( |
89
|
|
|
'The current <comment>%s</comment> build available remotely is: <comment>%s</comment>', |
90
|
|
|
$stability, |
91
|
|
|
$version |
92
|
|
|
)); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function noNewRemoteVersions(string $stability): void |
96
|
|
|
{ |
97
|
|
|
$this->io->writeln(sprintf('There are no new <comment>%s</comment> builds available.', $stability)); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function currentVersionInstalled(string $stability): void |
101
|
|
|
{ |
102
|
|
|
$this->io->writeln(sprintf('You have the current <comment>%s</comment> build installed.', $stability)); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.