Completed
Push — master ( fef7a6...aff413 )
by Arne
02:38
created

RestoreCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 34.62 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 9
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 9 9 1
A executeConfigured() 0 13 2

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 Archivr\Cli\Command;
4
5
use Archivr\ArchivR;
6
use Archivr\Cli\SynchronizationProgressListener;
7
use Archivr\Configuration;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class RestoreCommand extends AbstractConfiguredCommand
13
{
14 View Code Duplication
    protected function configure()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in 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...
15
    {
16
        parent::configure();
17
18
        $this->setName('restore');
19
        $this->setDescription('Restores the local state from the vault state.');
20
        $this->addOption('revision', 'r', InputOption::VALUE_REQUIRED, 'Restore given revision. Defaults to last revision.');
21
        $this->addOption('vault', null, InputOption::VALUE_REQUIRED, 'Vault to use to download state from.');
22
    }
23
24
    protected function executeConfigured(InputInterface $input, OutputInterface $output, Configuration $configuration): int
25
    {
26
        $archivr = new ArchivR($configuration);
27
        $archivr->restore(
28
            $input->getOption('revision') ? (int)$input->getOption('revision') : null,
29
            $input->getOption('vault'),
30
            new SynchronizationProgressListener($output)
31
        );
32
33
        $output->writeln(PHP_EOL . '<info>Done!</info>');
34
35
        return 0;
36
    }
37
}
38