MySQLDriver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A dsn() 0 13 2
1
<?php
2
namespace SimplePDO\Drivers;
3
4
use SimplePDO\Configuration;
5
use SimplePDO\Drivers\DriverInterface;
6
7
class MySQLDriver implements DriverInterface
8
{
9
10
    /**
11
     * {@inheritdoc}
12
     */
13
    final public static function dsn(Configuration $configuration)
14
    {
15
        $dbname = $configuration->get('MYSQL', 'DBNAME');
16
        $host = $configuration->get('MYSQL', 'HOST');
17
        $port = $configuration->get('MYSQL', 'PORT');
18
        $charset = $configuration->get('MYSQL', 'CHARSET');
19
        $socket = $configuration->get('MYSQL', 'SOCKET');
20
        
21
        if (!empty($socket))
22
        {
23
            return "mysql:dbname={$dbname};unix_socket{$socket};charset={$charset}";
24
        }
25
        return "mysql:dbname={$dbname};host={$host};port={$port};charset={$charset}";
26
    }
27
28
}
29