Completed
Push — master ( 19307d...e58f7e )
by Nekrasov
04:19 queued 02:31
created

Database   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 25
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
     * @throws Exception
16
     */
17
    public function __construct($connectionName = 'default')
18
    {
19
        $connections = Configuration::getInstance()->get('connections');
20
21
        if (!array_key_exists($connectionName, $connections)) {
22
            throw new Exception("Connection '$connectionName' is not found in .settings.php");
23
        }
24
25
        $connection = $connections[$connectionName];
26
27
        parent::__construct(
28
            "mysql:dbname={$connection['database']};host={$connection['host']}",
29
            $connection['login'],
30
            $connection['password']
31
        );
32
    }
33
}
34