RestoreCommand::executeConfigured()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 1
nop 3
1
<?php
2
3
namespace Storeman\Cli\Command;
4
5
use Storeman\Storeman;
6
use Storeman\Cli\SynchronizationProgressListener;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class RestoreCommand extends AbstractCommand
12
{
13 View Code Duplication
    protected function configure()
14
    {
15
        parent::configure();
16
17
        $this->setName('restore');
18
        $this->setDescription('Restores the local state from the vault state.');
19
        $this->addOption('revision', 'r', InputOption::VALUE_REQUIRED, 'Restore given revision. Defaults to last revision.');
20
        $this->addOption('vault', null, InputOption::VALUE_REQUIRED, 'Vault to use to download state from.');
21
    }
22
23 View Code Duplication
    protected function executeConfigured(InputInterface $input, OutputInterface $output, Storeman $storeman): int
24
    {
25
        $storeman->restore(
26
            $input->getOption('revision') ? (int)$input->getOption('revision') : null,
27
            $input->getOption('vault'),
28
            new SynchronizationProgressListener($output)
29
        );
30
31
        $output->writeln(PHP_EOL . '<info>Done!</info>');
32
33
        return 0;
34
    }
35
}
36