GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b88bc4...2341f0 )
by Benjamin
02:09
created

Connection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 36
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A createParams() 0 15 4
1
<?php
2
3
namespace Lib\DB\DBAL;
4
5
use Lib\DB\DBAL\Connection\ConnectionInterface;
6
use Lib\DB\DBAL\Driver\DriverInterface;
7
use Lib\DB\DBAL\Driver\PDODriver;
8
use Symfony\Component\Yaml\Parser;
9
10
class Connection
11
{
12
    /** @var DriverInterface */
13
    private $driver;
14
15
    /** @var ConnectionInterface */
16
    private $conn;
17
18
    /** @var bool */
19
    private $isConnected = false;
20
21 1
    public function __construct()
22
    {
23 1
        $parser = new Parser();
24 1
        $config = $parser->parseFile(__DIR__.'/../../../../config/config.yml')['database'];
25 1
        [$params, $username, $password] = $this->createParams($config);
26 1
        $this->driver = new PDODriver();
27 1
        $this->conn = $this->driver->connect($params, $username, $password);
28 1
        $this->isConnected = true;
29 1
    }
30
31 1
    private function createParams($config)
32
    {
33 1
        $username = '';
34 1
        $password = '';
35 1
        $params = [];
36 1
        foreach ($config as $key => $val) {
37 1
            if ($key === 'username') {
38 1
                $username = $val;
39 1
            } elseif ($key === 'password') {
40 1
                $password = $val;
41
            } else {
42 1
                $params[$key] = $val;
43
            }
44
        }
45 1
        return [$params, $username, $password];
46
    }
47
}
48