Sqlite   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 9
dl 0
loc 31
c 0
b 0
f 0
rs 10

1 Method

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