Failed Conditions
Push — v7 ( 137ba9...eb2dfc )
by Florent
03:53
created

RollbackCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace Jose\Component\Console\Command;
15
16
use Symfony\Component\Console\Command\Command;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
use Humbug\SelfUpdate\Updater;
20
21
final class RollbackCommand extends Command
22
{
23
    protected function configure()
24
    {
25
        $this
26
            ->setName('rollback')
27
            ->setDescription('Rollback current version.')
28
        ;
29
    }
30
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $updater = new Updater();
34
35
        try {
36
            $result = $updater->rollback();
37
            if (!$result) {
38
                echo "Failure!\n";
39
                exit(1);
0 ignored issues
show
Coding Style Compatibility introduced by
The method execute() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
40
            }
41
            echo "Success!\n";
42
        } catch (\Exception $e) {
43
            echo "Well, something happened! Either an oopsie or something involving hackers.\n";
44
            exit(1);
0 ignored issues
show
Coding Style Compatibility introduced by
The method execute() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
45
        }
46
    }
47
}
48