GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

RollbackCommand::execute()   B
last analyzed

Complexity

Conditions 5
Paths 9

Size

Total Lines 26
Code Lines 17

Duplication

Lines 5
Ratio 19.23 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
dl 5
loc 26
rs 8.439
c 3
b 0
f 0
cc 5
eloc 17
nc 9
nop 2
1
<?php
2
3
namespace Dami\Cli\Command;
4
5
use Symfony\Component\Console\Input\InputInterface,
6
    Symfony\Component\Console\Input\InputArgument,
7
    Symfony\Component\Console\Output\OutputInterface;
8
9
class RollbackCommand extends ContainerAwareCommand
10
{
11
    protected function configure()
12
    {
13
        parent::configure();
14
15
        $this
16
            ->setDescription('Rollback migrations.')
17
            ->addArgument('to-version', InputArgument::OPTIONAL, 'Rollback to specific version of migrations');
18
    }
19
20
    protected function execute(InputInterface $input, OutputInterface $output)
21
    {
22
        parent::execute($input, $output);
23
24
        $version = $input->getArgument('to-version');
25
        $migration = $this->getContainer()->get('dami.migration');
26
27
        $message = function($name, $version) use ($output) {
28
                $output->write(sprintf("\n<comment>Migration %s %s</comment>",
29
                    $version, $name));
30
        };
31
        if (null === $version) {
32
            $numberMigrations = $migration->migrateToPreviousVersion($message);
33
        } else {
34
            if ($version === 'all') {
35
                $version = 0;
36
            }
37
            $numberMigrations = $migration->migrate($version, $message);
38
        }
39
40 View Code Duplication
        if (0 === $numberMigrations) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
            $output->writeln(sprintf("<comment>Nothing migrations detected to rollback.</comment>"));
42
        } elseif ($numberMigrations > 1) {
43
            $output->writeln(sprintf("\n<info>%d migrations were rollbacked.</info>", $numberMigrations));
44
        }
45
    }
46
}
47