Completed
Push — master ( 8e94f8...744b49 )
by P.R.
04:26
created

AuditCommand::auditColumnTypes()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 5

Importance

Changes 5
Bugs 0 Features 0
Metric Value
c 5
b 0
f 0
dl 0
loc 23
ccs 19
cts 19
cp 1
rs 8.5906
cc 5
eloc 13
nc 5
nop 0
crap 5
1
<?php
2
//----------------------------------------------------------------------------------------------------------------------
3
namespace SetBased\Audit\MySql\Command;
4
5
use SetBased\Audit\MySql\Audit;
6
use SetBased\Audit\MySql\AuditDataLayer;
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\Output\OutputInterface;
11
12
//----------------------------------------------------------------------------------------------------------------------
13
/**
14
 * Command for creating audit tables and audit triggers.
15
 */
16
class AuditCommand extends MySqlBaseCommand
17
{
18
  //--------------------------------------------------------------------------------------------------------------------
19
  /**
20
   * {@inheritdoc}
21
   */
22 10
  protected function configure()
23
  {
24 10
    $this->setName('audit')
25 10
         ->setDescription('Create (missing) audit table and (re)creates audit triggers')
26 10
         ->addArgument('config file', InputArgument::OPTIONAL, 'The audit configuration file');
27 10
  }
28
29
  //--------------------------------------------------------------------------------------------------------------------
30
  /**
31
   * {@inheritdoc}
32
   */
33 9
  protected function execute(InputInterface $input, OutputInterface $output)
34
  {
35 9
    $this->io = new StratumStyle($input, $output);
36
37 9
    $this->configFileName = $input->getArgument('config file');
38 9
    $this->readConfigFile();
39
40
    // Create database connection with params from config file
41 9
    $this->connect($this->config);
42
43 9
    $audit = new Audit($this->config, $this->io);
44 9
    $audit->main();
45
46
    // Drop database connection
47 9
    AuditDataLayer::disconnect();
48
49 9
    $this->rewriteConfig();
50 9
  }
51
52
  //--------------------------------------------------------------------------------------------------------------------
53
}
54
55
//----------------------------------------------------------------------------------------------------------------------
56