Passed
Push — master ( bbf0da...682cd1 )
by Emmanuel
02:36
created

DriverGuesser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDBHelper() 0 22 2
1
<?php
2
/**
3
 * neuralyzer : Data Anonymization Library and CLI Tool
4
 *
5
 * PHP Version 7.1
6
 *
7
 * @author Emmanuel Dyan
8
 * @copyright 2018 Emmanuel Dyan
9
 *
10
 * @package edyan/neuralyzer
11
 *
12
 * @license GNU General Public License v2.0
13
 *
14
 * @link https://github.com/edyan/neuralyzer
15
 */
16
17
namespace Edyan\Neuralyzer\Helper\DB;
18
19
/**
20
 * Help to find the right DB Type from a driver
21
 */
22
class DriverGuesser
23
{
24
    public static function getDBHelper(string $driver)
25
    {
26
        $drivers = [
27
            'pdo_mysql'  => MySQL::class,
28
            'mysql'      => MySQL::class,
29
            'mysql2'     => MySQL::class,
30
31
            'pdo_pgsql'  => PostgreSQL::class,
32
            'pgsql'      => PostgreSQL::class,
33
            'postgres'   => PostgreSQL::class,
34
            'postgresql' => PostgreSQL::class,
35
36
            'pdo_sqlsrv' => SQLServer::class,
37
            'mssql'      => SQLServer::class,
38
        ];
39
40
        if (!array_key_exists($driver, $drivers)) {
41
            throw new \InvalidArgumentException("$driver unknown");
42
        }
43
44
        return $drivers[$driver];
45
    }
46
}
47