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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 26
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A connect() 0 9 2
A createDsn() 0 9 3
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