Establish an API connection.

@param  array  $config
@return self
164062
public function connect(array $config)
    {
        $connection = $this->createConnection($config);

        $this->validateCredentials($config);

        // For basic authentication we need an Authorization
        // header to be set. We add it to the request here.
        $this->addHeader(
            'Authorization',
            'Basic ' . base64_encode(
                array_get($config, 'identifier') . ':' . array_get($config, 'secret')
            )
        );

        return $connection;
    }
510034
protected function createReadWriteConnection(array $config)
    {
        $connection = $this->createSingleConnection($this->getWriteConfig($config));

        return $connection->setReadPdo($this->createReadPdo($config));
    }
919402
public static function factory($config = array())
    {
        $configuration = static::buildConfig($config);

        $client = new self($configuration->get('base_url'), $configuration);

        $client->addSubscriber(new KeyAuthPlugin($configuration->get('key')));

        static::loadDefinitions($client);
        static::toggleRateLimitingPlugin($client, $config);

        return $client;
    }
159701
public function init(array $config = []) : self
    {
        $host = $config[RouterConfig::ROUTER_CONNECTION_HOST] ?? RouterConfig::AMQP_RABBIT_DEFAULT_HOST;
        $port = $config[RouterConfig::ROUTER_CONNECTION_PORT] ?? RouterConfig::AMQP_RABBIT_DEFAULT_PORT;
        $login = $config[RouterConfig::ROUTER_CONNECTION_LOGIN] ?? RouterConfig::AMQP_RABBIT_DEFAULT_LOGIN;
        $password = $config[RouterConfig::ROUTER_CONNECTION_PASSWORD] ?? RouterConfig::AMQP_RABBIT_DEFAULT_PASSWORD;
        $vhost = $config[RouterConfig::ROUTER_CONNECTION_VHOST] ??  RouterConfig::AMQP_RABBIT_DEFAULT_VHOST;
        
        $defaultServer = new RouterServer(
            $host, 
            $port,
            $login, 
            $password,
            $vhost,
            RouterConfig::SERVER_TAG_DEFAULT
        );
        
        $this->registry->registerServer($defaultServer);
        
        return $this;
    }
1348949
public function make(array $config)
    {
        Arr::requires($config, ['from', 'client', 'token']);

        $client = new Client();

        return new TwilioGateway($client, $config);
    }
865711
public function connect(array $config)
    {
        $auth = $this->getAuth($config);
        $client = $this->getClient($auth);

        return $this->getAdapter($client);
    }
1110482
public function load(array $config)
    {
        $config = $this->getParsedConfig(
            $config,
            $this->config,
            $this->yamlConfigMap,
            $this->required
        );
        $this->setParsedConfig($config);

        return $this;
    }
680510
protected function createSingleConnection(array $config)
    {
        $pdo = $this->createPdoResolver($config);

        return $this->createConnection(
            $config['driver'], $pdo, $config['database'], $config['prefix'], $config
        );
    }
143080
public function connect(array $config)
	{
		return new DatabaseQueue(
			$this->connections->connection(Arr::get($config, 'connection')),
			$config['table'],
			$config['queue'],
			Arr::get($config, 'expire', 60)
		);
	}
1207556
public function connect(array $config): PDO
    {
        if (isset($config['options']) === false) {
            $config['options'] = [];
        }

        return $this->doConnect($config);
    }
854781
public function mergeConfig(array $config): self
    {
        $this->config = array_merge($this->config, $config);

        return $this;
    }
312863
public function connect(array $config)
    {
        $ironConfig = ['token' => $config['token'], 'project_id' => $config['project']];

        if (isset($config['host'])) {
            $ironConfig['host'] = $config['host'];
        }

        $iron = new IronMQ($ironConfig);

        if (isset($config['ssl_verifypeer'])) {
            $iron->ssl_verifypeer = $config['ssl_verifypeer'];
        }

        $queue = new IronQueue($iron, $this->request, $config['queue'], $config['encrypt'], $config['timeout']);
        $queue->setEncrypter($this->crypt);

        return $queue;
    }
1150673
public function connect(array $config)
	{
		$dsn = $this->getDsn($config);
		$options = $this->getOptions($config);

		// We need to grab the PDO options that should be used while making the brand
		// new connection instance. The PDO options control various aspects of the
		// connection's behavior, and some might be specified by the developers.
		$this->pdo = $this->createConnection($dsn, $config, $options);

		$this->configureEncoding($config);

		// Next, we will check to see if a timezone has been specified in this config
		// and if it has we will issue a statement to modify the timezone with the
		// database. Setting this DB timezone is an optional configuration item.
		$this->configureTimezone($config);
		$this->setModes($config);

		return $this->pdo;
	}
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']}]" );
	}
1044685
public function connect(array $config)
    {
        $options = $this->options($config);

        // SQLite provides supported for "in-memory" databases, which exist only for
        // lifetime of the request. These are mainly for tests.
        if ($config['database'] == ':memory:') {
            return new \Pimf\Database('sqlite::memory:', null, null, $options);
        }

        return new \Pimf\Database('sqlite:' . $config['database'], null, null, $options);
    }
701141
public function createConnection(array $config)
    {
        if (! isset($config['host'])) {
            throw new InvalidArgumentException("No host provided.");
        }

        $this->setHost($config['host']);

        // We check the configuration for request headers. Some API's require
        // certain headers for all requests. Providing them in the configuration
        // makes it easier to provide these headers on each request.
        if (isset($config['headers'])) {
            $this->setHeaders($config['headers']);
        }

        return $this;
    }
698442
private function setup(array $config) {
		$r = new C(null, $config + [
			'timeout' => 120
			/**
			 * 2017-07-16
			 * By default it is «Zend_Http_Client»: @see C::$config
			 * https://github.com/magento/zf1/blob/1.13.1/library/Zend/Http/Client.php#L126
			 */
			,'useragent' => 'Mage2.PRO'
		]); /** @var C $r */
		/** @var aProxy|aSocket $a */
		if (!($p = $this->proxy())) {  /** @var IProxy $p */
			$a = new aSocket;
		}
		else {
			// 2019-01-14
			// https://framework.zend.com/manual/1.12/en/zend.http.client.adapters.html#zend.http.client.adapters.proxy
			$a = new aProxy;
			$r->setConfig([
				'proxy_host' => $p->host()
				,'proxy_pass' => $p->password()
				,'proxy_port' => $p->port()
				,'proxy_user' => $p->username()
			]);
		}
		if ($p || !$this->verifyCertificate()) {
			$ssl = ['allow_self_signed' => true, 'verify_peer' => false]; /** @var array(string => bool) $ssl */
			if ($p) {
				// 2019-01-14 It is needed for my proxy: https://stackoverflow.com/a/32047219
				$ssl['verify_peer_name'] = false;
			}
			$a->setStreamContext(['ssl' => $ssl]);
		}
		$r->setAdapter($a);
		return $r;
	}