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   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 13.16 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 6
lcom 0
cbo 4
dl 5
loc 38
rs 10
c 3
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
B execute() 5 26 5

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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