Rollback::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 0
cts 9
cp 0
rs 9.6666
cc 2
eloc 6
nc 2
nop 2
crap 6
1
<?php
2
3
namespace Releaser;
4
5
use Humbug\SelfUpdate\Updater;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class Rollback extends Command
11
{
12
    const DISTRIBUTION_PREFIX = 'https://limit-zero.github.io/releaser/';
13
14
    protected function configure()
15
    {
16
        $this
17
            ->setName('rollback')
18
            ->setDescription('Rolls back releaser.phar to the last version')
19
        ;
20
    }
21
22
    protected function execute(InputInterface $input, OutputInterface $output)
23
    {
24
        $updater = new Updater();
25
        $result = $updater->rollback();
26
        if (!$result) {
27
            throw new \Exception('Unable to rollback');
28
        }
29
        $output->writeln(sprintf('Successfully rolled back to %s', $updater->getNewVersion()));
30
    }
31
}
32