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