|
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) |
|
|
|
|
|
|
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
|
|
|
|
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.