@param string $driver

@throws \Exception
196641
public static function setConfigDriver(string $driver) {
        if(!(self::$core instanceof AgileCore)) {
            throw new \Exception('please init core first!');
        }

        self::$config->setDriverType($driver);
    }
866183
protected function driverExcludedByOptions(string $driver, array $options): bool
    {
        return (! empty($options['only']) && ! \in_array($driver, (array) $options['only'])) ||
            (! empty($options['except']) && \in_array($driver, (array) $options['except']));
    }
40316
protected function setupDriverConfig(string $driver): ?array
    {
        if (isset($this->config[$driver])) {
            return null;
        }

        if (\is_null($config = Arr::pull($this->config, "drivers.{$driver}"))) {
            return null;
        }

        $connection = $this->config['connection'] ?? null;

        if (! \is_null($connection) && $this->driverExcludedByOptions($driver, $connection['options'])) {
            $connection = null;
        }

        return $this->config[$driver] = \array_merge($config, ['connection' => $connection]);
    }
1327960
public function setDriver(\BearFramework\App\ICacheDriver $driver): self
    {
        if ($this->driver !== null) {
            throw new \Exception('A cache driver is already set!');
        }
        $this->driver = $driver;
        return $this;
    }
1221955
protected function createDriver($driver)
    {
        $config = config("payments.{$driver}", null);
        if (is_string($config)) {
            return $this->createDriver($config);
        }
        if ($config === null) {
            throw new InvalidArgumentException("Driver [$driver] not supported.");
        }
        $provider = $config['provider'] ?? null;

        // We'll check to see if a creator method exists for the given driver. If not we
        // will check for a custom driver creator, which allows developers to create
        // drivers using their own customized driver creator Closure to create it.
        if (isset($this->customCreators[$provider])) {
            $config['shop'] = $driver;
            return tap(
                $this->callCustomCreator($provider, $config),
                function (PaymentProviderInterface $provider) use ($driver) {
                    $provider->setLogger(
                        new Logger($driver, [new RotatingFileHandler(storage_path("logs/{$driver}.log"))])
                    );
                }
            );
        }
        throw new InvalidArgumentException("Provider [$provider] not supported.");
    }
162929
public static function useNewDatabaseDriver($configuration): void
    {
        static::throwExceptionIfHasStarted();

        $driver = new Database();
        $driver->setNewDatabase($configuration);

        static::$driver = $driver;
    }
941272
public function addDriver(DriverInterface $driver)
    {
        $driver->setConnector($this);
        $this->driverList[$driver->getDriverId()] = $driver;

        return $this;
    }
193194
protected function createDriver($driver)
    {
        // We'll check to see if a creator method exists for the given driver. If not we
        // will check for a custom driver creator, which allows developers to create
        // drivers using their own customized driver creator Closure to create it.
        if (isset($this->customCreators[$driver])) {
            return $this->callCustomCreator($driver);
        } else {
            $method = 'create'.Stringy::create($driver)->upperCamelize().'Driver';

            if (method_exists($this, $method)) {
                return $this->$method();
            }
        }
        throw new InvalidArgumentException("Driver [$driver] not supported.");
    }
197323
public function create(string $driver, array $options = []){
        if(!class_exists($driver)){
            throw new \InvalidArgumentException();
        }

        $driver   = new $driver($options);

        if(!($driver instanceof Driver\AbstractDriver)){
            throw new \InvalidArgumentException();
        }

        return $driver;
    }
513248
public static function requireDriver($driver)
    {
        if (empty($driver)) {
            throw new \Exception("Database driver name can not be empty.");
        }

        // clients now use indirect association to drivers, dblib can be sqlsrv or sqlanywhere
        if ('dblib' === $driver) {
            $driver = 'sqlsrv';
        }
        $pdoDriver = null;
        switch ($driver) {
            case 'ibm':
                if (!extension_loaded('ibm_db2')) {
                    throw new \Exception("Required extension 'ibm_db2' is not detected, but may be compiled in.");
                }
                $pdoDriver = 'ibm';
                break;
            case 'mysql':
                if (!extension_loaded('mysql') && !extension_loaded('mysqlnd')) {
                    throw new \Exception("Required extension 'mysql' is not detected, but may be compiled in.");
                }
                $pdoDriver = 'mysql';
                break;
            case 'oracle':
                if (!extension_loaded('oci8')) {
                    throw new \Exception("Required extension 'oci8' is not detected, but may be compiled in.");
                }
                break;
            case 'pgsql':
                if (!extension_loaded('pgsql')) {
                    throw new \Exception("Required extension 'pgsql' is not detected, but may be compiled in.");
                }
                $pdoDriver = 'pgsql';
                break;
            case 'sqlanywhere':
                $extension = 'mssql';
                if (!extension_loaded($extension)) {
                    throw new \Exception("Required extension 'mssql' is not detected, but may be compiled in.");
                }
                $pdoDriver = 'dblib';
                break;
            case 'sqlite':
                if (!extension_loaded('sqlite3')) {
                    throw new \Exception("Required extension 'sqlite3' is not detected, but may be compiled in.");
                }
                $pdoDriver = 'sqlite';
                break;
            case 'sqlsrv':
                $pdoDriver = 'sqlsrv';
                $extension = 'sqlsrv';

                if (!extension_loaded($extension)) {
                    $pdoDriver = 'dblib';
                    $extension = 'mssql';
                    if (!extension_loaded($extension)) {
                        throw new \Exception("Required extension '$extension' is not detected, but may be compiled in.");
                    }
                }
                break;
            default:
                throw new \Exception("Driver '$driver' is not supported by this software.");
                break;
        }

        if ($pdoDriver) {
            static::checkForPdoDriver($pdoDriver);
        }

        return true;
    }
714207
private function startServer($driver = null)
    {
        if (! $driver) {
            $driver = $this->driver;
        }

        $this->info(sprintf('Starting %s server on: %s:%d', $this->option('driver'), $this->host, $this->port));

        $this->createServerInstance();

        $this->{'start'.$driver}()->run();
    }
852555
public function setDriver($driver) {

    	if(false === is_string($driver)) {
    		return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($driver)), E_USER_ERROR);
    	}

        if(false === class_exists($driver)) {

            $driver = __NAMESPACE__ . '\\Driver\\' . $driver;
        
            if(false === class_exists($driver)) {
        		return trigger_error(sprintf('Driver "%s" does not exists', $driver), E_USER_ERROR);
        	}
        }

        $this -> driver = $driver;

        return $this;
    }
513152
public function driver($driver = null)
    {
        $driver = $driver ?: $this->getDefaultDriver();

        if (! isset($this->drivers[$driver])) {
            $this->drivers[$driver] = $this->createDriver($driver);
        }

        return $this->drivers[$driver];
    }
660887
protected function validateDriver($driver)
    {
        $interface = $this->interface();

        if (! (new ReflectionClass($driver))->implementsInterface($interface)) {
            throw new InvalidDriverException(get_class($driver)." does not implement {$interface}");
        }

        return $driver;
    }
921291
public function removeFromBackupDrivers($driver)
    {
        if ($driver instanceof Driver) {
            $driver = $driver->name;
        }
        if (in_array($driver, $this->backupDrivers)) {
            $index = array_search($driver, $this->backupDrivers);
            array_splice($this->backupDrivers, $index, 1);
        }
    }
253048
private static function createDriver()
    {
        if (self::$factory === null) {
            throw new \Exception("No loop driver factory set; Either pass a driver to Loop::execute or set a factory.");
        }

        $driver = self::$factory->create();

        if (!$driver instanceof Driver) {
            $type = is_object($driver) ? "an instance of " . get_class($driver) : gettype($driver);
            throw new \Exception("Loop driver factory returned {$type}, but must return an instance of Driver.");
        }

        return $driver;
    }
1065515
public function driver(string $driver)
    {
        if (isset($this->drivers[$driver])) {
            $provider = $driver . 'Provider';
            if (method_exists($this, $provider)) {
                return $this->$provider();
            }

            return new $this->drivers[$driver](
                $this->getRequest(),
                $this->config,
                $this->getSession()
            );
        }

        if (class_exists($driver)) {
            $driver = new $driver(
                $this->getRequest(),
                $this->config,
                $this->getSession()
            );

            if ($driver instanceof Two\AbstractProvider) {
                return $driver;
            }
        }

        throw new \InvalidArgumentException("Driver not supported.");
    }