SqlAdapter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A map() 0 13 1
A normalizeDriver() 0 10 1
1
<?php namespace Nord\Lumen\Doctrine\ORM\Configuration;
2
3
use Nord\Lumen\Doctrine\ORM\Contracts\ConfigurationAdapter as ConfigurationAdapterContract;
4
5
class SqlAdapter implements ConfigurationAdapterContract
6
{
7
8
    /**
9
     * @inheritdoc
10
     */
11
    public function map(array $config)
12
    {
13
        return [
14
            'driver'   => $this->normalizeDriver($config['driver']),
15
            'host'     => $config['host'],
16
            'port'     => $config['port'],
17
            'dbname'   => $config['database'],
18
            'user'     => $config['username'],
19
            'password' => $config['password'],
20
            'charset'  => $config['charset'],
21
            'prefix'   => array_get($config, 'prefix'),
22
        ];
23
    }
24
25
26
    /**
27
     * @param $driver
28
     *
29
     * @return string
30
     */
31
    private function normalizeDriver($driver)
32
    {
33
        $driverMap = [
34
            'mysql'  => 'pdo_mysql',
35
            'pgsql'  => 'pdo_pgsql',
36
            'sqlsrv' => 'pdo_sqlsrv',
37
        ];
38
39
        return $driverMap[$driver];
40
    }
41
}
42