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

MySqlBaseCommand::connect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 10
ccs 8
cts 8
cp 1
rs 9.4285
cc 1
eloc 7
nc 1
nop 1
crap 1
1
<?php
2
//----------------------------------------------------------------------------------------------------------------------
3
namespace SetBased\Audit\MySql\Command;
4
5
use SetBased\Audit\Command\BaseCommand;
6
use SetBased\Audit\MySql\AuditDataLayer;
7
8
//----------------------------------------------------------------------------------------------------------------------
9
/**
10
 * Base class for commands which needs to connect to a MySQL instance.
11
 */
12
class MySqlBaseCommand extends BaseCommand
13
{
14
  //--------------------------------------------------------------------------------------------------------------------
15
  /**
16
   * Disconnects from MySQL instance.
17
   */
18
  public function disconnect()
19
  {
20
    AuditDataLayer::disconnect();
21
  }
22
23
  //--------------------------------------------------------------------------------------------------------------------
24
  /**
25
   * Connects to a MySQL instance.
26
   *
27
   * @param array $settings The settings from the configuration file.
28
   */
29 9
  protected function connect($settings)
30
  {
31 9
    $host     = $this->getSetting($settings, true, 'database', 'host');
32 9
    $user     = $this->getSetting($settings, true, 'database', 'user');
33 9
    $password = $this->getSetting($settings, true, 'database', 'password');
34 9
    $database = $this->getSetting($settings, true, 'database', 'data_schema');
35
36 9
    AuditDataLayer::setIo($this->io);
37 9
    AuditDataLayer::connect($host, $user, $password, $database);
38 9
  }
39
40
  //--------------------------------------------------------------------------------------------------------------------
41
}
42
43
//----------------------------------------------------------------------------------------------------------------------
44