Completed
Branch master (0ecb66)
by P.R.
04:50
created

MySqlBaseCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 72.72%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 30
ccs 8
cts 11
cp 0.7272
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A disconnect() 0 4 1
A connect() 0 10 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