Completed
Pull Request — master (#57)
by Dima
02:53
created

DiffCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 12 1
1
<?php
2
//----------------------------------------------------------------------------------------------------------------------
3
namespace SetBased\Audit\MySql\Command;
4
5
use SetBased\Audit\MySql\AuditDataLayer;
6
use SetBased\Audit\MySql\AuditDiff;
7
use SetBased\Stratum\Style\StratumStyle;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Input\InputOption;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
//----------------------------------------------------------------------------------------------------------------------
14
/**
15
 * Command for comparing data tables with audit tables.
16
 */
17
class DiffCommand extends AuditCommand
18
{
19
  //--------------------------------------------------------------------------------------------------------------------
20
  /**
21
   * Check full full and return array without new or obsolete columns if full not set.
22
   *
23
   * @param array[] $columns The metadata of the columns of a table.
24
   *
25
   * @var StratumStyle
26
   */
27
  protected $io;
28
29
  //--------------------------------------------------------------------------------------------------------------------
30
  /**
31
   * {@inheritdoc}
32
   */
33 5
  protected function configure()
34
  {
35 5
    $this->setName('diff')
36 5
         ->setDescription('Compares data tables and audit tables')
37 5
         ->addArgument('config file', InputArgument::OPTIONAL, 'The audit configuration file', 'etc/audit.json')
38 5
         ->addOption('full', 'f', InputOption::VALUE_NONE, 'Show all columns');
39 5
  }
40
41
  //--------------------------------------------------------------------------------------------------------------------
42
  /**
43
   * {@inheritdoc}
44
   */
45 4
  protected function execute(InputInterface $input, OutputInterface $output)
46
  {
47 4
    $this->io = new StratumStyle($input, $output);
48
49 4
    $this->configFileName = $input->getArgument('config file');
50 4
    $this->readConfigFile();
51
52 4
    $this->connect($this->config);
53
54 4
    $diff = new AuditDiff($this->config, $this->configMetadata, $this->io, $input, $output);
55 4
    $diff->main();
56 4
  }
57
58
  //--------------------------------------------------------------------------------------------------------------------
59
60
}
61
62
//----------------------------------------------------------------------------------------------------------------------
63