Test Setup Failed
Push — master ( 4c0917...56b13c )
by Php Easy Api
04:17
created

Mysql::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Migratio\Connector;
4
5
use Migratio\GrammarStructure\Mysql\QueryBase;
6
7
class Mysql extends QueryBase
8
{
9
    /**
10
     * @var $instance
0 ignored issues
show
Documentation Bug introduced by
The doc comment $instance at position 0 could not be parsed: Unknown type name '$instance' at position 0 in $instance.
Loading history...
11
     */
12
    private static $instance;
13
14
    /**
15
     * @var $connection
0 ignored issues
show
Documentation Bug introduced by
The doc comment $connection at position 0 could not be parsed: Unknown type name '$connection' at position 0 in $connection.
Loading history...
16
     */
17
    protected $connection;
18
19
    /**
20
     * @var mixed
21
     */
22
    protected $config;
23
24
    /**
25
     * Mysql constructor.
26
     * @param $config
27
     */
28
    public function __construct($config)
29
    {
30
        $this->config = $config;
31
32
        if(is_null(self::$instance)){
33
34
            //get pdo dsn
35
            $dsn=''.$config['driver'].':host='.$config['host'].';dbname='.$config['database'].'';
36
            $this->connection = new \PDO($dsn, $config['user'], $config['password']);
37
            $this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
38
39
            self::$instance=true;
40
        }
41
    }
42
43
    /**
44
     * get config
45
     *
46
     * @return mixed
47
     */
48
    public function getConfig()
49
    {
50
        return $this->config;
51
    }
52
53
    /**
54
     * @return \PDO
55
     */
56
    public function getConnection()
57
    {
58
        return $this->connection;
59
    }
60
61
}