Passed
Push — master ( ca1995...557dce )
by Théo
03:14 queued 55s
created

UpdateConsoleLogger::rollbackSuccess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the humbug/php-scoper package.
7
 *
8
 * Copyright (c) 2017 Théo FIDRY <[email protected]>,
9
 *                    Pádraic Brady <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Humbug\PhpScoper\Logger;
16
17
use Symfony\Component\Console\Style\SymfonyStyle;
18
19
/**
20
 * @private
21
 * @final
22
 */
23
class UpdateConsoleLogger
24
{
25
    /**
26
     * @var SymfonyStyle
27
     */
28
    private $io;
29
30
    public function __construct(SymfonyStyle $io)
31
    {
32
        $this->io = $io;
33
    }
34
35
    public function startUpdating()
36
    {
37
        $this->io->writeln('Updating...');
38
    }
39
40
    public function updateSuccess(string $newVersion, string $oldVersion)
41
    {
42
        $this->io->success('PHP-Scoper has been updated.');
43
        $this->io->writeln(sprintf(
44
            'Current version is: <comment>%s</comment>.',
45
            $newVersion
46
        ));
47
        $this->io->writeln(sprintf(
48
            'Previous version was: <comment>%s</comment>.',
49
            $oldVersion
50
        ));
51
    }
52
53
    public function updateNotNeeded(string $oldVersion)
54
    {
55
        $this->io->writeln('PHP-Scoper is currently up to date.');
56
        $this->io->writeln(sprintf(
57
            'Current version is: <comment>%s</comment>.',
58
            $oldVersion
59
        ));
60
    }
61
62
    public function error(\Throwable $e)
0 ignored issues
show
Unused Code introduced by
The parameter $e is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
63
    {
64
        $this->io->error('Unexpected error. If updating, your original phar is untouched.');
65
    }
66
67
    public function rollbackSuccess()
68
    {
69
        $this->io->success('PHP-Scoper has been rolled back to prior version.');
70
    }
71
72
    public function rollbackFail()
73
    {
74
        $this->io->error('Rollback failed for reasons unknown.');
75
    }
76
77
    public function printLocalVersion(string $version)
78
    {
79
        $this->io->writeln(sprintf(
80
            'Your current local version is: <comment>%s</comment>',
81
            $version
82
        ));
83
    }
84
85
    public function printRemoteVersion(string $stability, string $version)
86
    {
87
        $this->io->writeln(sprintf(
88
            'The current <comment>%s</comment> build available remotely is: <comment>%s</comment>',
89
            $stability,
90
            $version
91
        ));
92
    }
93
94
    public function noNewRemoteVersions(string $stability)
95
    {
96
        $this->io->writeln(sprintf('There are no new <comment>%s</comment> builds available.', $stability));
97
    }
98
99
    public function currentVersionInstalled(string $stability)
100
    {
101
        $this->io->writeln(sprintf('You have the current <comment>%s</comment> build installed.', $stability));
102
    }
103
}
104