Database   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getInstance() 0 7 2
1
<?php
2
namespace GJClasses;
3
4
class Database
5
{
6
    public $cnxx;
7
    private static $instance;
8
9
    private function __construct()
10
    {
11
        $this->cnxx = new \PDO("mysql:host=" . GJC_DB_HOSTNAME . ";dbname=" . GJC_DB_NAME . ";charset=utf8", GJC_DB_USERNAME, GJC_DB_PASSWORD);
12
        $this->cnxx->exec("SET NAMES utf8");
13
        $this->cnxx->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
14
        $this->cnxx->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_OBJ);
15
        $this->cnxx->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
16
    }
17
18
    public static function getInstance()
19
    {
20
        if (!isset(self::$instance)) {
21
            $object = __CLASS__;
22
            self::$instance = new $object;
23
        }
24
        return self::$instance;
25
    }
26
}
27