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 ( 2e753f...99a73b )
by Benjamin
03:04
created

Connection::__construct()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 25
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
eloc 16
nc 3
nop 0
dl 0
loc 25
ccs 0
cts 23
cp 0
crap 30
rs 8.439
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
        $config = array_walk(
19
            $config,
20
            function ($val, $key) use ($keys, $userpass) {
21
                if (!\in_array($key, $keys)) {
22
                    if (\in_array($key, ['username', 'password'])) {
23
                        $userpass[$key] = $val;
24
                    }
25
                    unset($config[$key]);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $config seems to be never defined.
Loading history...
26
                }
27
            }
28
        );
29
        foreach ($keys as $key) {
30
            if (isset($config[$key])) {
31
                $dsn .= "{$key}={$config[$key]};";
32
            }
33
        }
34
        parent::__construct($dsn, $userpass['username'], $userpass['password'], []);
35
    }
36
}
37