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 ( 21cf6c...173932 )
by Benjamin
03:31 queued 48s
created

Connection::createParams()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 12
nc 4
nop 1
dl 0
loc 17
ccs 13
cts 13
cp 1
crap 4
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace Lib\DB\DBAL;
4
5
use Lib\DB\DBAL\Connection\ConnectionInterface;
6
use Lib\DB\DBAL\Driver\DriverInterface;
7
use Lib\DB\DBAL\Driver\PDODriver;
8
use Symfony\Component\Yaml\Parser;
9
10
class Connection
11
{
12
    /** @var DriverInterface */
13
    private $driver;
14
15
    /** @var ConnectionInterface */
16
    private $conn;
17
18
    /** @var bool */
19
    private $isConnected = false;
20
21 1
    public function __construct()
22
    {
23 1
        $parser = new Parser();
24 1
        $config = $parser->parseFile(__DIR__.'/../../../../config/config.yml')['database'];
25 1
        [$params, $username, $password] = $this->createParams($config);
26 1
        $this->driver = new PDODriver();
27 1
        $this->conn = $this->driver->connect($params, $username, $password);
28 1
        $this->isConnected = true;
29 1
    }
30
31 1
    private function createParams($config)
32
    {
33 1
        $username = '';
34 1
        $password = '';
35 1
        $params = [];
36 1
        foreach ($config as $key => $val) {
37 1
            if ($key === 'username') {
38 1
                $username = $val;
39 1
                continue;
40
            }
41 1
            if ($key === 'password') {
42 1
                $password = $val;
43 1
                continue;
44
            }
45 1
            $params[$key] = $val;
46
        }
47 1
        return [$params, $username, $password];
48
    }
49
}
50