Database   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 0
cbo 1
dl 0
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 2
1
<?php
2
3
namespace Arrilot\BitrixDataAnonymization;
4
5
use Arrilot\DataAnonymization\Database\SqlDatabase;
6
use Bitrix\Main\Config\Configuration;
7
use Bitrix\Main\DB\Exception;
8
9
class Database extends SqlDatabase
10
{
11
    /**
12
     * Constructor.
13
     *
14
     * @param string $connectionName
15
     *
16
     * @throws Exception
17
     */
18
    public function __construct($connectionName = 'default')
19
    {
20
        $connections = Configuration::getInstance()->get('connections');
21
22
        if (!array_key_exists($connectionName, $connections)) {
23
            throw new Exception("Connection '$connectionName' is not found in .settings.php");
24
        }
25
26
        $connection = $connections[$connectionName];
27
28
        parent::__construct(
29
            "mysql:dbname={$connection['database']};host={$connection['host']}",
30
            $connection['login'],
31
            $connection['password']
32
        );
33
    }
34
}
35