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.

PDODriver   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 28
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 10 2
A createDsn() 0 10 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lib\DB\DBAL\Driver;
6
7
use Lib\DB\DBAL\Connection\ConnectionInterface;
8
use Lib\DB\DBAL\Connection\PDOConnection;
9
use PDO;
10
11
class PDODriver implements DriverInterface
12
{
13
    private const KEYS = ['host', 'port', 'dbname', 'unix_socket', 'charset'];
14
15 1
    public function connect(array $params, $username, $password): ConnectionInterface
16
    {
17 1
        $password = getenv('TEST') ? '' : $password;
18
19 1
        return new PDOConnection(
20 1
            $this->createDsn($params),
21 1
            $username,
22 1
            $password,
23
            [
24 1
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
25
            ]
26
        );
27
    }
28
29 1
    private function createDsn($params)
30
    {
31 1
        $dsn = 'mysql:';
32 1
        foreach (self::KEYS as $key) {
33 1
            if (isset($params[$key])) {
34 1
                $dsn .= "{$key}={$params[$key]};";
35
            }
36
        }
37
38 1
        return $dsn;
39
    }
40
}
41