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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 0
cts 23
cp 0
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 25 5
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