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.

Factory   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B get() 0 23 6
1
<?php
2
/**
3
 * Database
4
 *
5
 * @copyright Copyright (c)  Gjero Krsteski (http://krsteski.de)
6
 * @license   http://opensource.org/licenses/MIT MIT License
7
 */
8
9
namespace Pimf\Pdo;
10
11
/**
12
 * Creates a PDO connection from the farm of connectors.
13
 *
14
 * @package Database
15
 * @author  Gjero Krsteski <[email protected]>
16
 */
17
class Factory
18
{
19
    /**
20
     * @param array $config
21
     *
22
     * @return \Pimf\Database
23
     * @throws \RuntimeException If no driver specified or no PDO installed.
24
     * @throws \UnexpectedValueException
25
     */
26
    public static function get(array $config)
27
    {
28
        if (!isset($config['driver']) || !$config['driver']) {
29
            throw new \RuntimeException('no driver specified');
30
        }
31
32
        $driver = strtolower($config['driver']);
33
34
        if (!in_array($driver, array('sqlite', 'mysql', 'sqlserver', 'postgre'), true)) {
35
            throw new \UnexpectedValueException('PDO driver "' . $driver . '" not supported by PIMF');
36
        }
37
38
        if (!extension_loaded('pdo') || !extension_loaded('pdo_' . $driver)) {
39
            throw new \RuntimeException('Please navigate to "http://php.net/manual/pdo.installation.php" '
40
                . ' to find out how to install "PDO" with "pdo_' . $driver . '" on your system!');
41
        }
42
43
        $driver = '\Pimf\Pdo\\' . ucfirst($driver);
44
45
        $pdo = new $driver();
46
47
        return $pdo->connect($config);
48
    }
49
}
50