public function driver($driver = null, $config = [])
{
if ($driver === null) {
return $this->_driver;
}
if (is_string($driver)) {
$className = App::className($driver, 'Database/Driver');
if (!$className || !class_exists($className)) {
throw new MissingDriverException(['driver' => $driver]);
}
$driver = new $className($config);
}
if (!$driver->enabled()) {
throw new MissingExtensionException(['driver' => get_class($driver)]);
}
return $this->_driver = $driver;
}