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.

Postgre::connect()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 22

Duplication

Lines 22
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
nc 8
nop 1
dl 22
loc 22
rs 9.568
c 0
b 0
f 0
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
 * Connection management to PostgreSQL
13
 *
14
 * @package Database
15
 * @author  Gjero Krsteski <[email protected]>
16
 */
17
class Postgre extends Connector
18
{
19
    protected $options = array(
20
        \PDO::ATTR_CASE              => \PDO::CASE_LOWER,
21
        \PDO::ATTR_ERRMODE           => \PDO::ERRMODE_EXCEPTION,
22
        \PDO::ATTR_ORACLE_NULLS      => \PDO::NULL_NATURAL,
23
        \PDO::ATTR_STRINGIFY_FETCHES => false,
24
    );
25
26
    /**
27
     * @param array $config
28
     *
29
     * @return \Pimf\Database
30
     */
31 View Code Duplication
    public function connect(array $config)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $dsn = "pgsql:host={$config['host']};dbname={$config['database']}";
34
35
        if (isset($config['port'])) {
36
            $dsn .= ";port={$config['port']}";
37
        }
38
39
        $connection = new \Pimf\Database($dsn, $config['username'], $config['password'], $this->options($config));
40
41
        // set to UTF-8 which should be fine for most scenarios.
42
        if (isset($config['charset'])) {
43
            $connection->prepare("SET NAMES '{$config['charset']}'")->execute();
44
        }
45
46
        // If a schema has been specified
47
        if (isset($config['schema'])) {
48
            $connection->prepare("SET search_path TO '{$config['schema']}'")->execute();
49
        }
50
51
        return $connection;
52
    }
53
}
54