Completed
Push — master ( 70f940...e223fc )
by Mr
02:00
created

Sqlite   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 27
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A genDsn() 0 10 3
1
<?php
2
3
namespace DrMVC\Database\Drivers;
4
5
class Sqlite extends SQL
6
{
7
    /**
8
     * @link https://secure.php.net/manual/en/ref.pdo-mysql.connection.php
9
     *
10
     * The PDO_SQLITE Data Source Name (DSN) is composed of the following elements:
11
     */
12
    const AVAILABLE_ELEMENTS = [
13
        'path',
14
    ];
15
16
    /**
17
     * Generate DSN by parameters in config
18
     *
19
     * @param   array $config
20
     * @return  string
21
     */
22
    public function genDsn($config): string
23
    {
24
        // Parse config
25
        $dsn = '';
26
        foreach ($config as $key => $value) {
27
            if (\in_array($key, self::AVAILABLE_ELEMENTS, false)) {
28
                $dsn .= $value;
29
            }
30
        }
31
        return $dsn;
32
    }
33
34
}
35