Completed
Branch master (0ecb66)
by P.R.
04:50
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 2
Bugs 0 Features 0
Metric Value
c 2
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
 * Base class for commands which needs to connect to a MySQL instance.
10
 */
11
class MySqlBaseCommand extends BaseCommand
12
{
13
  //--------------------------------------------------------------------------------------------------------------------
14
  /**
15
   * Disconnects from MySQL instance.
16
   */
17
  public function disconnect()
18
  {
19
    AuditDataLayer::disconnect();
20
  }
21
22
  //--------------------------------------------------------------------------------------------------------------------
23
  /**
24
   * Connects to a MySQL instance.
25
   *
26
   * @param array $settings The settings from the configuration file.
27
   */
28 26
  protected function connect($settings)
29
  {
30 26
    $host     = $this->getSetting($settings, true, 'database', 'host');
31 26
    $user     = $this->getSetting($settings, true, 'database', 'user');
32 26
    $password = $this->getSetting($settings, true, 'database', 'password');
33 26
    $database = $this->getSetting($settings, true, 'database', 'data_schema');
34
35 26
    AuditDataLayer::setIo($this->io);
36 26
    AuditDataLayer::connect($host, $user, $password, $database);
37 26
  }
38
39
  //--------------------------------------------------------------------------------------------------------------------
40
}
41
42
//----------------------------------------------------------------------------------------------------------------------
43