Failed Conditions
Push — v7 ( 12d27f...276ae4 )
by Florent
03:49
created

RollbackCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 14 3
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;
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
/**
22
 * Class RollbackCommand.
23
 */
24
final class RollbackCommand extends Command
25
{
26
    protected function configure()
27
    {
28
        $this
29
            ->setName('rollback')
30
            ->setDescription('Rollback current version.')
31
        ;
32
    }
33
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $updater = new Updater();
37
38
        try {
39
            if (!$updater->rollback()) {
40
                $output->write('Failure!');
41
            } else {
42
                $output->write('Success!');
43
            }
44
        } catch (\Exception $e) {
45
            $output->write('Well, something happened! Either an oopsie or something involving hackers.');
46
        }
47
    }
48
}
49