Create a new driver instance.

@param string $name

@throws \InvalidArgumentException

@return GatewayInterface
554822
protected function createGateway($name)
    {
        if (isset($this->customCreators[$name])) {
            $gateway = $this->callCustomCreator($name);
        } else {
            $className = $this->formatGatewayClassName($name);
            $gateway = $this->makeGateway($className);
        }

        if (!($gateway instanceof GatewayInterface)) {
            throw new InvalidArgumentException(sprintf('Gateway "%s" not inherited from %s.', $name, GatewayInterface::class));
        }

        return $gateway;
    }
208234
public static function createFromName($name)
    {
        $value = array_search($name, static::$names, true);

        if (!$value) {
            throw new InvalidArgumentException(sprintf(
                'Level with name "%s" is not in list: %s',
                $name,
                implode(', ', static::$names)
            ));
        }

        return new static($value);
    }
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.");
    }
678469
protected function makeService($name)
    {
        $config = $this->getConfig($name);

        // First we will check by the service name to see if an extension has been
        // registered specifically for that service. If it has we will call the
        // Closure and pass it the config allowing it to resolve the service.
        if (isset($this->extensions[$name])) {
            return call_user_func($this->extensions[$name], $config, $name);
        }

        $config = $this->getDbConfig($name);
        $type = $config['type'];

        // Next we will check to see if a type extension has been registered for a service type
        // and will call the factory Closure if so, which allows us to have a more generic
        // resolver for the service types themselves which applies to all services.
        if (isset($this->types[$type])) {
            return $this->types[$type]->make($name, $config);
        }

        throw new InvalidArgumentException("Unsupported service type '$type'.");
    }
1238881
protected function resolve($name)
    {
        $config = $this->app['config']->get(\sprintf('log.channels.%s', $name));

        if (is_null($config)) {
            throw new \InvalidArgumentException(\sprintf('Log [%s] is not defined.', $name));
        }

        if (isset($this->customCreators[$config['driver']])) {
            return $this->callCustomCreator($config);
        }

        $driverMethod = 'create'.ucfirst($config['driver']).'Driver';

        if (method_exists($this, $driverMethod)) {
            return $this->{$driverMethod}($config);
        }

        throw new \InvalidArgumentException(\sprintf('Driver [%s] is not supported.', $config['driver']));
    }
179149
public function get(string $name): TemplateInterface
    {
        if (!isset($this->engines[$name])) {
            throw new InvalidArgumentException('Template engine "' . $name . '" is not known or registered');
        }

        return $this->engines[$name];
    }
1078243
private function createMethod(string $name): MethodInterface
    {
        $class = 'Ekyna\\Component\\Dpd\\EPrint\\Method\\' . ucwords($name);
        if (class_exists($class)) {
            /** @var MethodInterface $instance */
            return new $class($this->getClient());
        }

        throw new RuntimeException("Method {$name} does not exist");
    }
730298
protected function adapterFactory(string $name): AdapterInterface
	{
		$factory = $this->adapterFactories[$name];

		return $this->adapters[$name] = $factory();
	}
1013899
protected static function createOmnipayGateway(string $gatewayClassName): GatewayInterface
    {
        $craftClient = Craft::createGuzzleClient();
        $adapter = new Client($craftClient);
        $httpClient = new OmnipayClient($adapter);

        return Omnipay::create($gatewayClassName, $httpClient);
    }
128435
protected function createFluentDriver($name)
    {
        $config = Arr::get($this->config, "fluent.{$name}", []);
        $cache  = $this->getCacheRepository($config);

        return $this->createProvider(new Fluent($name, $config, $this->app->make('db'), $cache));
    }
65921
private static function createFromConfig($name): Storage\StorageInterface
    {
        $config = &self::$config['storage'][$name];
        $driver = &$config['driver'];
        $config = &$config['config'];

        return new self::$driver[$driver]($config);
    }
777054
protected function createDriver($driver)
    {
        if (isset($this->initialDrivers[$driver])) {
            $provider = $this->initialDrivers[$driver];
            $provider = __NAMESPACE__.'\\Providers\\'.$provider.'Provider';

            return $this->buildProvider($provider, $this->formatConfig($this->config->get($driver)));
        }

        if (isset($this->customCreators[$driver])) {
            return $this->callCustomCreator($driver);
        }

        throw new InvalidArgumentException("Driver [$driver] not supported.");
    }
1330132
public function createDocument($name)
    {
        $doc = $this->extensions->createDocument($name);
        if ($doc) {
            return $doc;
        }

        throw new \InvalidArgumentException(sprintf('Unknown document "%s"', $name));
    }
760018
protected function createRuntimeDriver(string $name): ProviderContract
    {
        $config = $this->config['runtime'][$name] ?? [];

        return $this->createProvider(new Runtime($name, $config));
    }
192829
public function factory($name)
    {
        if (isset($this->factories[$name])) {
            return $this->factories[$name];
        }

        if (class_exists($class = $this->inflect($name))) {
            return $this->factories[$name] = new $class();
        }

        throw new InvalidArgumentException("Unsupported factory [$name].");
    }
383736
public static function create($name)
    {
        $name = strtolower($name);
        $classname = self::__getClassName($name);
        $path = self::__getDriverPath($name);

        if (!is_file($path)) {
            throw new Exception(
                __('Could not find Email Gateway %s.', array('<code>' . $name . '</code>'))
                . ' ' . __('If it was provided by an Extension, ensure that it is installed, and enabled.')
            );
        }

        if (!class_exists($classname)) {
            require_once $path;
        }

        return new $classname;
    }
220231
private function buildDriver($name, array $driver)
    {
        return $this->drivers[$name] = new $driver['driver'](
            Arr::get($driver, 'options.'.$this->getDefaultOption(), [])
        );
    }