Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | 6 | public static function create($connection_options) |
|
30 | { |
||
31 | $drivers = [ |
||
32 | 6 | "Oci8" => "Drone\Db\Driver\Oracle", |
|
33 | "Mysqli" => "Drone\Db\Driver\MySQL", |
||
34 | "Sqlsrv" => "Drone\Db\Driver\SQLServer", |
||
35 | ]; |
||
36 | |||
37 | 6 | if (!array_key_exists('driver', $connection_options)) { |
|
38 | 1 | throw new \RuntimeException("The database driver key has not been declared"); |
|
39 | } |
||
40 | |||
41 | 5 | $drv = $connection_options["driver"]; |
|
42 | |||
43 | 5 | if (array_key_exists($drv, $drivers)) { |
|
44 | 4 | return new $drivers[$drv]($connection_options); |
|
45 | } else { |
||
46 | 1 | throw new \RuntimeException("The database driver does not exists"); |
|
47 | } |
||
50 |