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

Sqlite::genDsn()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
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