Completed
Pull Request — master (#40)
by Dima
03:24
created

DiffCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 29.27 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 42.86%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 2
c 4
b 1
f 0
lcom 1
cbo 5
dl 12
loc 41
ccs 6
cts 14
cp 0.4286
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 12 12 1

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 SetBased\Audit\MySql\Command;
4
5
use SetBased\Audit\MySql\AuditDiff;
6
use SetBased\Stratum\Style\StratumStyle;
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
//----------------------------------------------------------------------------------------------------------------------
13
/**
14
 * Command for comparing data tables with audit tables.
15
 */
16
class DiffCommand extends AuditCommand
17
{
18
  //--------------------------------------------------------------------------------------------------------------------
19
  /**
20
   * The Output decorator.
21
   *
22
   * @var StratumStyle
23
   */
24
  protected $io;
25
26
  //--------------------------------------------------------------------------------------------------------------------
27
  /**
28
   * {@inheritdoc}
29
   */
30 1
  protected function configure()
31
  {
32 1
    $this->setName('diff')
33 1
         ->setDescription('Compares data tables and audit tables')
34 1
         ->addArgument('config file', InputArgument::OPTIONAL, 'The audit configuration file', 'etc/audit.json')
35 1
         ->addOption('full', 'f', InputOption::VALUE_NONE, 'Show all columns');
36 1
  }
37
38
  //--------------------------------------------------------------------------------------------------------------------
39
  /**
40
   * {@inheritdoc}
41
   */
42 View Code Duplication
  protected function execute(InputInterface $input, OutputInterface $output)
0 ignored issues
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...
43
  {
44
    $this->io = new StratumStyle($input, $output);
45
46
    $this->configFileName = $input->getArgument('config file');
47
    $this->readConfigFile();
48
49
    $this->connect($this->config);
50
51
    $diff = new AuditDiff($this->config, $this->io, $input, $output);
52
    $diff->main();
53
  }
54
55
  //--------------------------------------------------------------------------------------------------------------------
56
}
57
58
//----------------------------------------------------------------------------------------------------------------------
59