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.

Connection::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Rentgen\Database\Connection;
4
5
class Connection
6
{
7
    private $connection;
8
    private $config;
9
10
    /**
11
     * Constructor.
12
     *
13
     * @param ConnectionConfigInterface $config Connection config.
14
     */
15
    public function __construct(ConnectionConfigInterface $config)
16
    {
17
       $this->config = $config;
18
    }
19
20
    /**
21
     * Execute sql query.
22
     *
23
     * @param string $sql Sql query.
24
     *
25
     * @return integer
26
     */
27
    public function execute($sql)
28
    {
29
        return $this->getConnection()->exec($sql);
30
    }
31
32
    /**
33
     * Execute sql and expect return a data.
34
     *
35
     * @param string $sql Sql query.
36
     *
37
     * @return array
38
     */
39
    public function query($sql)
40
    {
41
        $rows = array();
42
        foreach ($this->getConnection()->query($sql) as $row) {
43
            $rows[] = $row;
44
        }
45
46
        return $rows;
47
    }
48
49
    private function getConnection()
50
    {
51
        if (null === $this->connection) {
52
            try {
53
                $this->connection = new \PDO($this->config->getDsn(), $this->config->getUsername(), $this->config->getPassword(),
54
                    array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION));
55
            } catch (\PDOException $exception) {
56
                throw new \InvalidArgumentException($exception->getMessage());
57
            }
58
        }
59
60
        return $this->connection;
61
    }
62
}
63