Create a new gateway instance.

@param string[] $config

@throws \InvalidArgumentException

@return \NotifyMeHQ\Contracts\GatewayInterface
433796
public function make(array $config)
    {
        if (!isset($config['driver'])) {
            throw new InvalidArgumentException('A driver must be specified.');
        }

        return $this->factory($config['driver'])->make($config);
    }
1207757
protected function createPdoResolverWithHosts(array $config)
    {
        return function () use ($config) {
            foreach (Arr::shuffle($hosts = $this->parseHosts($config)) as $key => $host) {
                $config['host'] = $host;

                try {
                    return $this->createConnector($config)->connect($config);
                } catch (PDOException $e) {
                    continue;
                }
            }

            throw $e;
        };
    }
1114148
public function make(array $config)
    {
        Arr::requires($config, ['token']);

        $client = new Client();

        return new BallouGateway($client, $config);
    }
1171866
public function configure(array $config = [])
    {
        if (isset($config['email'])) {
            if (! is_array($config['email'])) {
                throw new InvalidArgumentException('Email configuration should be an array.');
            }
            $this->emailConfig = $config['email'];
        }

        // Check if config has defined a tempDir
        if (isset($config['tempDir']) && is_dir($config['tempDir'])) {
            $this->tempDir = $config['tempDir'];
        }

        return $this;
    }
565174
public static function create(array $config = [])
    {
        if (!isset($config['driver'])) {
            throw new InvalidArgumentException("'driver' in config missing");
        }
        if (!isset($config['drivers'][$config['driver']])) {
            throw new InvalidArgumentException("driver '{$config['driver']}' is not configured");
        }
        if (!isset($config['drivers'][$config['driver']]['tagHeaderName'])) {
            throw new InvalidArgumentException("'tagHeaderName' is not configured");
        }

        $driverConfig = $config['drivers'][$config['driver']];
        $driverClass = $driverConfig['class'] ?? self::DRIVERS_NAMESPACE . '\\' . ucfirst($config['driver']);

        // tagHeaderName and tagHeaderDelimiter are not relevant to the Purger
        unset($driverConfig['tagHeaderName'], $driverConfig['tagHeaderDelimiter']);
        return \Craft::createObject($driverClass,[$driverConfig + ['useLocalTags' => $config['useLocalTags']]]);

    }
902227
public function createConnector( array $config )
	{
		if ( !isset( $config['driver'] ) )
			throw new InvalidArgumentException( 'A driver must be specified.' );

		switch ( $config['driver'] )
		{
			case 'mysql':
				return new MySqlConnector;
			case 'pgsql':
				return new PostgresConnector;
			case 'sqlite':
				return new SQLiteConnector;
			case 'sqlsrv':
				return new SqlServerConnector;
		}

		throw new InvalidArgumentException( "Unsupported driver [{$config['driver']}]" );
	}
1081219
public static function factory($config = array()) {
        $default = array(
            'serverUrls' => null,
            'user' => null,
            'publicKey' => null,
            'privateKey' => null,
        );

        // Backwards-compatibility with old client where user === publicKey
        if (!isset($config['user']) && isset($config['publicKey'])) {
            $config['user'] = $config['publicKey'];
        }

        $required = array('serverUrls', 'publicKey', 'privateKey', 'user');
        $config = Collection::fromConfig($config, $default, $required);

        if (!is_array($serverUrls = $config->get('serverUrls')) || empty($serverUrls)) {
            throw new InvalidArgumentException('serverUrls must be an array');
        }

        // Create the client and attach the service description
        return new self($serverUrls[0], $config);
    }
1211776
public function create(array $config = [])
    {
        if (null === $this->handler) {
            $this->handler = DefaultHandler::create();
        }

        return new Client(
            array_merge_recursive(
                [
                    'verify'  => false,
                    'handler' => $this->handler,
                ],
                $config
            )
        );
    }
899352
public static function createRedisByConfig(array $config) {
        $Redis = new Connection();
        $Redis->setHost(@$config['host'])
            ->setPort(@$config['port']);
        (isset($config['persistent']))      && $Redis->setPersistent($config['persistent']);
        (isset($config['connect_timeout'])) && $Redis->setConnectTimeout($config['connect_timeout']);
        (isset($config['connect_tries']))   && $Redis->setConnectTries($config['connect_tries']);
        return $Redis;
    }
430113
public static function make(array $config)
    {
        $builder = self::getBuilder();
        $configObject = $builder->build($config);
        $grid = new Grid($configObject);
        return $grid;
    }
141815
protected function makePay($gateway)
    {
        $app = new $gateway($this->config);

        if ($app instanceof GatewayInterface) {
            return $app->pay($this->gateway, $this->payload);
        }

        throw new InvalidGatewayException("Pay Gateway [{$gateway}] Must Be An Instance Of GatewayInterface");
    }
1013797
public function authenticate(array $config)
    {
        if (!$this->client) {
            throw new InvalidArgumentException('The client instance was not given to the password authenticator.');
        }

        if (!array_key_exists('username', $config) || !array_key_exists('password', $config)) {
            throw new InvalidArgumentException('The password authenticator requires a username and password.');
        }

        $this->client->authenticate(Client::AUTH_HTTP_PASSWORD, $config['username'], $config['password']);

        return $this->client;
    }
880753
public function authenticate(array $config)
    {
        if (!$this->client) {
            throw new InvalidArgumentException('The client instance was not given to the password authenticator.');
        }

        if (!array_key_exists('username', $config) || !array_key_exists('password', $config)) {
            throw new InvalidArgumentException('The password authenticator requires a username and password.');
        }

        $this->client->authenticate($config['username'], $config['password'], 'http_password');

        return $this->client;
    }
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;
    }
358476
public static function instance($config = [])
    {
        if (null === self::$instance) {
            self::$instance = new static($config);
        }

        return self::$instance;
    }
692169
public static function createFromArray(array $config)
    {
        $self = new self();

        if (!empty($config['base_url'])) {
            $self->setBaseUrl($config['base_url']);
        }

        if (!empty($config['auth_path'])) {
            $self->setAuthPath($config['auth_path']);
        }

        if (!empty($config['api_path'])) {
            $self->setApiPath($config['api_path']);
        }

        if (!empty($config['debug'])) {
            $self->setDebug($config['debug']);
        }

        if (!empty($config['auth'])) {
            $self->setAuth($config['auth']);
        }

        return $self;
    }
824576
public function createFtpDriver(array $config)
    {
        $ftpConfig = Arr::only($config, [
            'host', 'username', 'password', 'port', 'root', 'passive', 'ssl', 'timeout',
        ]);

        return $this->adapt($this->createFlysystem(
            new FtpAdapter($ftpConfig), $config
        ));
    }