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 ( 17f115...b66b27 )
by Benjamin
02:30
created

Connection::__construct()   B

Complexity

Conditions 6
Paths 12

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
cc 6
eloc 14
nc 12
nop 0
dl 0
loc 22
ccs 0
cts 21
cp 0
crap 42
rs 8.6737
c 0
b 0
f 0
1
<?php
2
3
namespace Lib\Db\Dbal;
4
5
use PDO;
6
use Symfony\Component\Yaml\Parser;
7
8
class Connection extends PDO
9
{
10
    public function __construct()
11
    {
12
        $keys     = ['host', 'port', 'dbname', 'unix_socket', 'charset'];
13
        $parser   = new Parser();
14
        $config   = $parser->parseFile(__DIR__.'/../../../../config/config.yml')['database'];
15
        $dsn      = $config['type'].';';
16
        $userpass = [];
17
18
        foreach ($config as $key => $val) {
19
            if (!\in_array($key, $keys)) {
20
                if (\in_array($key, ['username', 'password'])) {
21
                    $userpass[$key] = $val;
22
                }
23
                unset($config[$key]);
24
            }
25
        }
26
        foreach ($keys as $key) {
27
            if (isset($config[$key])) {
28
                $dsn .= "{$key}={$config[$key]};";
29
            }
30
        }
31
        parent::__construct($dsn, $userpass['username'], $userpass['password'], []);
32
    }
33
}
34