src/Drivers/DriverManager.php
public static function loadFromName($name, array $config, Request $request = null)
    {
        /*
        * Use the driver class basename without "Driver" if we're dealing with a
        * DriverInterface object.
        */
        if (class_exists($name) && is_subclass_of($name, DriverInterface::class)) {
            $name = preg_replace('#(Driver$)#', '', basename(str_replace('\\', '/', $name)));
        }
        /*
         * Use the driver name constant if we try to load a driver by it's
         * fully qualified class name.
         */
        if (class_exists($name) && is_subclass_of($name, HttpDriver::class)) {
            $name = $name::DRIVER_NAME;
        }
        if (is_null($request)) {
            $request = Request::createFromGlobals();
        }
        foreach (self::getAvailableDrivers() as $driver) {
            /** @var HttpDriver $driver */
            $driver = new $driver($request, $config, new Curl());
            if ($driver->getName() === $name) {
                return $driver;
            }
        }

        return new NullDriver($request, [], new Curl());
    }
public static function loadFromName($name, array $config, Request $request = null)
    {
        /*
        * Use the driver class basename without "Driver" if we're dealing with a
        * DriverInterface object.
        */
        if (class_exists($name) && is_subclass_of($name, DriverInterface::class)) {
            $name = preg_replace('#(Driver$)#', '', basename(str_replace('\\', '/', $name)));
        }
        /*
         * Use the driver name constant if we try to load a driver by it's
         * fully qualified class name.
         */
        if (class_exists($name) && is_subclass_of($name, HttpDriver::class)) {
            $name = $name::DRIVER_NAME;
        }
        if (is_null($request)) {
            $request = Request::createFromGlobals();
        }
        foreach (self::getAvailableDrivers() as $driver) {
            /** @var HttpDriver $driver */
            $driver = new $driver($request, $config, new Curl());
            if ($driver->getName() === $name) {
                return $driver;
            }
        }

        return new NullDriver($request, [], new Curl());
    }
public static function loadFromName ( $ name , array $ config , Request $ request = null ) { /*
        * Use the driver class basename without "Driver" if we're dealing with a
        * DriverInterface object.
        */ if ( class_exists ( $ name ) && is_subclass_of ( $ name , DriverInterface :: class ) ) { $ name = preg_replace ( '#(Driver$)#' , '' , basename ( str_replace ( '\\' , '/' , $ name ) ) ) ; } /*
         * Use the driver name constant if we try to load a driver by it's
         * fully qualified class name.
         */ if ( class_exists ( $ name ) && is_subclass_of ( $ name , HttpDriver :: class ) ) { $ name = $ name :: DRIVER_NAME ; } if ( is_null ( $ request ) ) { $ request = Request :: createFromGlobals ( ) ; } foreach ( self :: getAvailableDrivers ( ) as $ driver ) { /** @var HttpDriver $driver */ $ driver = new $ driver ( $ request , $ config , new Curl ( ) ) ; if ( $ driver -> getName ( ) === $ name ) { return $ driver ; } } return new NullDriver ( $ request , [ ] , new Curl ( ) ) ; }
Load a driver by using its name.

@param string $name
@param array $config
@param Request|null $request
@return mixed|HttpDriver|NullDriver
Load a driver by using its name .