Get a driver instance.

@param  string       $driver
@param  string|null  $option

@return \Arcanedev\Hasher\Contracts\HashDriver
428292
public function with($option = null, $driver = null)
    {
        return $this->option($option)->driver($driver);
    }
538820
public static function driver($uri, ConfigInterface $config = null)
    {
        return new Driver(self::formatUri($uri), $config);
    }
1265515
public static function getConnection($driver)
    {
        $driver = strtolower($driver);

        if (empty(static::$connections[$driver])) {
            return null;
        }

        return static::$connections[$driver];
    }
10969
public function get($key, $replacement = array(), $locale = null, $driver = null) {
       $driver = ! is_null($driver) ? $this->getDriver($driver) : $this->driver();

        return $driver
            ->get($key, $replacement, $locale);
    }
599400
public static function setDriver($driver, $env = null)
    {
        $file = realpath(dirname(__FILE__)."/../drivers/$driver.php");
        if (!file_exists($file)) {
            Log::log("ERROR: Driver file $file does not exists");
            return null;
        }
        self::$_driver[self::selectEnvironment($env)] = $driver;
        include_once $file;
    }
820114
public static function __getInstance($dsn, $user = null, $passwd = null, array $driverOptions = array())
    {
        if (!self::$instance) {
            self::$instance = new self($dsn, $user, $passwd, $driverOptions);
        }
        return self::$instance;
    }
726165
public static function getDbo($driver = null, $option = [], $forceNew = false)
    {
        // No driver name given, we return default DB object.
        if (!$driver) {
            return self::$db;
        }

        // Create new instance if this driver not exists.
        if (empty(self::$instances[$driver]) || $forceNew) {
            self::$instances[$driver] = static::createDbo($driver, $option);

            // Set default DB object.
            if (!self::$db) {
                self::$db = self::$instances[$driver];
            }
        }

        return self::$instances[$driver];
    }
344208
public function getDriver($driver = null)
    {
        $driverName = $driver ? $driver : Config::get('driver');
        if (is_array($driverName)) {
            // 驱动为数组，表示类的某个方法
            if (!is_callable($driverName)) {
                throw new BadMethodCallException('Method Not Found: ' . $driverName[0] . '->' . $driverName[1] . '()');
            }

            return call_user_func_array($driverName, []);
        } elseif (is_object($driverName)) {
            // 驱动为对象直接返回
            return $driverName;
        } elseif (is_string($driverName)) {
            // 驱动为字符串，为内置驱动
            $driver = 'create' . ucfirst($driverName) . 'Driver';
            if (!method_exists($this, $driver)) {
                throw new BadMethodCallException("Mailer driver {$driverName} not exist");
            }
        }


        return $this->$driver();
    }
947708
public static function createInstance($driver, $options)
    {
        if(!in_array($driver, self::$_validDrivers)) {
            throw new \Exception("Driver '{$driver}' not implemented");
        }

        $class = __NAMESPACE__ . '\\Driver\\' . $driver;

        $driver = new $class;
        $driver->setOptions($options);

        return new Storage($driver);
    }
951047
protected function getExporter($driver)
    {
        if (!array_key_exists($driver, static::$drivers)) {
            return $this->getDefaultExporter();
        }

        return new static::$drivers[$driver]($this->grid);
    }
167304
private function getDriver(): \BearFramework\App\IDataDriver
    {
        if ($this->driver !== null) {
            return $this->driver;
        }
        throw new \Exception('No data driver specified! Use useFileDriver() or setDriver() to specify one.');
    }
220231
private function buildDriver($name, array $driver)
    {
        return $this->drivers[$name] = new $driver['driver'](
            Arr::get($driver, 'options.'.$this->getDefaultOption(), [])
        );
    }
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;
    }
1200619
public function driver(AbstractDriver $driver = null)
    {
        if ($driver === null) {
            return $this->getDriver();
        }

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

		// If the given driver has not been created before, we will create the instances
		// here and cache it so we can return it next time very quickly. If there is
		// already a driver created by this name, we'll just return that instance.
		if ( !array_key_exists( $driver, $this->drivers ) )
			$this->drivers[$driver] = $this->createDriver( $driver );

		return $this->drivers[$driver];
	}
564244
public static function create( $name = null, $driver = 'file' ) 
	{
		if ( is_null( $name ) ) 
		{
			return new static( null, $driver );
		}
		
		if ( !isset( static::$instances[$name] ) ) 
		{
			static::$instances[$name] = new static( $name, $driver );
		}
		
		return static::$instances[$name];
	}
227420
public function getService($driver)
    {
        if ($driver = explode(':', $driver) and
            isset($driver[0]) and
            $driver = explode('.', $driver[0]) and
            isset($driver[1])
        ) {
            return $this->container->get($driver[0] . '.' . $driver[1] . '_bundle.manager.' . $driver[1] . '_manager');
        }
    }