Passed
Branch master (f36b3c)
by Matthew
08:01
created

Mysql   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 24
ccs 4
cts 4
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDsn() 0 3 1
A open() 0 3 1
A __construct() 0 3 1
1
<?php
2
namespace Fyuze\Database\Drivers;
3
4
use PDO;
5
6
class Mysql extends Driver
7
{
8
    /**
9
     * @param $config
10
     */
11 2
    public function __construct($config)
12
    {
13 2
        $this->config = $config;
14
    }
15
16
    /**
17
     * @codeCoverageIgnore
18
     */
19
    public function open()
20
    {
21
        return new PDO($this->getDsn(), $this->config['username'], $this->config['password'], $this->getOptions());
22
    }
23
24
    /**
25
     * @return string
26
     */
27 1
    protected function getDsn()
28
    {
29 1
        return sprintf('mysql:host=%s;dbname=%s', $this->config['host'], $this->config['database']);
30
    }
31
}
32