DumpCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 85.19 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 10 10 1
A executeConfigured() 13 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 Storeman\Cli\Command;
4
5
use Storeman\Storeman;
6
use Storeman\Cli\SynchronizationProgressListener;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class DumpCommand extends AbstractCommand
13
{
14 View Code Duplication
    protected function configure()
15
    {
16
        parent::configure();
17
18
        $this->setName('dump');
19
        $this->setDescription('Dump the contents of a vault.');
20
        $this->addArgument('path', InputArgument::REQUIRED, 'Target path.');
21
        $this->addOption('revision', 'r', InputOption::VALUE_REQUIRED, 'Restore given revision. Defaults to last revision.');
22
        $this->addOption('vault', null, InputOption::VALUE_REQUIRED, 'Vault to use to download state from.');
23
    }
24
25 View Code Duplication
    protected function executeConfigured(InputInterface $input, OutputInterface $output, Storeman $storeman): int
26
    {
27
        $storeman->dump(
28
            $input->getArgument('path'),
29
            $input->getOption(  'revision') ? (int)$input->getOption('revision') : null,
30
            $input->getOption('vault'),
31
            new SynchronizationProgressListener($output)
32
        );
33
34
        $output->writeln(PHP_EOL . '<info>Done!</info>');
35
36
        return 0;
37
    }
38
}
39