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.

DatabaseConnectionFactory::bootstrap()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php declare(strict_types=1);
2
/**
3
 * @license MIT
4
 * @author Samuel Adeshina <[email protected]>
5
 *
6
 * This file is part of the EmmetBlue project, please read the license document
7
 * available in the root level of the project
8
 */
9
namespace EmmetBlue\Core\Factory;
10
11
use EmmetBlue\Core\Connection\ConnectionAdapter as Connection;
12
use EmmetBlue\Core\Constant;
13
14
/**
15
 * Class DatabaseConnectionFactory.
16
 * Instantiates a new instance of ConnectableInterface
17
 *
18
 * @author Samuel Adeshina <[email protected]>
19
 *
20
 * @since v0.0.1 08/06/2016 14:20
21
 */
22
class DatabaseConnectionFactory
23
{
24
    /**
25
     * @var \PDO $connectionObject
26
     */
27
    private static $connectionObject;
28
29
    /**
30
     * Gets the config values defined in the database-config.json file
31
     * and uses the values to create a new connection object.
32
     */
33
    public static function bootstrap()
34
    {
35
        $databaseConfigJson = file_get_contents(Constant::getGlobals()["config-dir"]["database-config"]);
36
37
        $databaseConfig = json_decode($databaseConfigJson);
38
39
        $adapter = $databaseConfig->adapter;
40
        $server = $databaseConfig->server;
41
        $database = $databaseConfig->database;
42
        $username = $databaseConfig->username;
43
        $password = $databaseConfig->password;
44
45
        self::$connectionObject = new Connection($adapter, [$server, $database], $username, $password);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \EmmetBlue\Core\Conn..., $username, $password) of type object<EmmetBlue\Core\Co...tion\ConnectionAdapter> is incompatible with the declared type object<PDO> of property $connectionObject.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
46
47
        if ($databaseConfig->showError)
48
        {
49
            self::$connectionObject->getConnection()->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
50
        }
51
    }
52
53
    /**
54
     * Returns a new connection object
55
     * 
56
     * @return \PDO
57
     */
58
    public static function getConnection() : \PDO
59
    {
60
        self::bootstrap();
61
        return self::$connectionObject->getConnection();
62
    }
63
}
64