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

RestoreCommand::executePrepared()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 1
nop 3
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