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

PDODriver::createDsn()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: benjamin
5
 * Date: 13/01/19
6
 * Time: 23:21
7
 */
8
9
namespace Lib\DB\DBAL\Driver;
10
11
use Lib\DB\DBAL\Connection\ConnectionInterface;
12
use Lib\DB\DBAL\Connection\PDOConnection;
13
use PDO;
14
15
class PDODriver implements DriverInterface
16
{
17
    private const KEYS = ['host', 'port', 'dbname', 'unix_socket', 'charset'];
18
19 1
    public function connect(array $params, $username, $password): ConnectionInterface
20
    {
21 1
        $password = getenv("TEST") ? '' : $password;
22 1
        return new PDOConnection(
23 1
            $this->createDsn($params),
24 1
            $username,
25 1
            $password,
26
            [
27 1
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
28
            ]
29
        );
30
    }
31
32 1
    private function createDsn($params)
33
    {
34 1
        $dsn = 'mysql:';
35 1
        foreach (self::KEYS as $key) {
36 1
            if (isset($params[$key])) {
37 1
                $dsn .= "{$key}={$params[$key]};";
38
            }
39
        }
40 1
        return $dsn;
41
    }
42
}
43