Passed
Push — dev ( 382b50...7a587b )
by Greg
02:02
created

Database   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getInstance() 0 7 2
1
<?php
2
namespace GJClasses;
3
4
class Database
5
{
6
    public $cnxx;
7
    public $log;
8
    private static $instance;
9
10
    private function __construct()
11
    {
12
        $this->log = new Log('class.database');
0 ignored issues
show
Bug introduced by
The type GJClasses\Log was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
        $this->cnxx = new \PDO("mysql:host=" . DB_HOSTNAME . ";dbname=" . DB_NAME . ";charset=utf8", DB_USERNAME, DB_PASSWORD);
0 ignored issues
show
Bug introduced by
The constant GJClasses\DB_NAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant GJClasses\DB_PASSWORD was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant GJClasses\DB_HOSTNAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant GJClasses\DB_USERNAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
15
        $this->cnxx->exec("SET NAMES utf8");
16
        $this->cnxx->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
17
        $this->cnxx->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_OBJ);
18
        $this->cnxx->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
19
    }
20
21
    public static function getInstance()
22
    {
23
        if (!isset(self::$instance)) {
24
            $object = __CLASS__;
25
            self::$instance = new $object;
26
        }
27
        return self::$instance;
28
    }
29
}
30