@param array $config

@throws Exception
@return Gateway
180653
public static function newInstance($config = null)
	{

		if (!function_exists('curl_init')) {
			throw new Exception('Curl required');
		}

		$gateway = new self();

		if (null !== $config) {
			Config::setAll($config);
		}

		return $gateway;

	}
660668
public function connect( array $config )
	{
		$options = $this->getOptions( $config );

		$dsn = array_get( $config, 'dsn' );

		return $this->createConnection( $dsn, $config, $options );
	}
1010090
public function make(array $config)
    {
        Arr::requires($config, ['from', 'token']);

        $client = new Client();

        return new CampfireGateway($client, $config);
    }
1259940
public function make(array $config)
    {
        Arr::requires($config, ['token']);

        $client = new Client();

        return new SlackGateway($client, $config);
    }
274787
public function connect(array $config)
    {
        $ironConfig = array('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'];
        }

        return new IronQueue($iron, $this->request, $config['queue'], $config['encrypt']);
    }
381014
public function connect(array $config){
		Connection::alias($config, 'resource', 'pdo');

		// Defaults
		$defaults = array(
			'dsn' => null,
			'resource' => null,
			'username' => null,
			'password' => null,
			'options' => array(),
		);

		$config += $defaults;

		// Connect
		if($config['resource'] instanceof PDO)
			$this->resource = $config['resource'];
		else try{
			$this->resource = new PDO($config['dsn'], $config['username'], $config['password'], $config['options']);
		} catch(PDOException $e){
			throw new DriverException($e->getMessage(), $e->getCode());
		}

		if(!$this->resource)
			throw new DriverException('Connection failed.');

		$this->driverName = $this->resource->getAttribute(PDO::ATTR_DRIVER_NAME);
	}
1173645
private function getSessionHandler(array $config)
    {
        $handler = array_get($config, 'handler', 'default');

        // Build handler using a matching method "get{Type}Handler"
        $method = Str::camel("get_{$handler}_handler");
        if (method_exists($this, $method)) {
            return $this->{$method}($config);
        }

        /*
         * @todo Change this to return an exception if an unsupported handler is configured. This makes it easier to get
         * configuration dialed in properly
         */
        //throw new \RuntimeException(t('Unsupported session handler "%s"', $handler));

        // Return the default session handler by default
        return $this->getSessionHandler(['handler' => 'default'] + $config);
    }
372486
public function setConfig(array $config)
    {
        $this->config = array_merge($this->config, $config);

        if ($this->config[ 'responsive' ]) {
            $this->responsive();
        }

        return $this;
    }
115093
public function build(array $config)
    {
        $router = new Router();
        foreach ($config as $name => $route) {
            if ($route instanceof RouteInterface) {
                $router->register($name, $route);
                continue;
            }

            $route = $this->applyDefaults($route);

            $router->register(
                $name,
                $this->createDefinition($route)
            );
        }

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

        if ($this->container->bound($key = "db.connector.{$config['driver']}")) {
            return $this->container->make($key);
        }

        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']}]");
    }
1245811
public function config(array $config)
    {
        parent::config($config);

        if (array_key_exists('http_method', $config)) {
            $this->defaults->setHttpMethod($config['http_method']);
        }

        return $this;
    }
10065
public function connect(array $config)
    {
        /** @var CouchbaseConnection $connection */
        $connection = $this->connectionResolver->connection($config['driver']);

        return new CouchbaseQueue(
            $connection,
            $config['bucket'],
            $config['queue'],
            Arr::get($config, 'retry_after', 60)
        );
    }
60792
protected function setConfig(array $config = array())
    {
        $this->config = $config;

        if (isset($config['prefix'])) {
            $this->prefix = $config['prefix'];
        }

        if (isset($config['host'])) {
            $this->host = $config['host'];
        }

        if (isset($config['port'])) {
            $this->port = $config['port'];
        }

        return $this;
    }
573398
protected function createSwooleServer(array $config)
    {
        return new SwooleServer(
            $this->serverSocket->getHost(),
            $this->serverSocket->getPort(),
            $this->parseServerMode($config),
            $this->serverSocket->getSocketType()
        );
    }
84794
private function getInstanceHelper($config)
    {
        if (is_callable($config)) {
            return $config;
        }
        if (!isset($config['class_name'])) {
            throw new Exception\RuntimeException('Config router convert miss "class_name"');
        }
        $className = $config['class_name'];
        if (!class_exists($className)) {
            throw new Exception\RuntimeException(sprintf('"%s" is not existed', $className));
        }

        /**
         * @todo User can config parameter when create new object
         * @todo User can config call method after creating object
         */
        $object = new $className;

        return $object;
    }
675411
public function connect(array $config)
    {
        return new DatabaseQueue(
            $this->connections->connection($config['connection'] ?? null),
            $config['table'],
            $config['queue'],
            $config['retry_after'] ?? 60
        );
    }
1170779
protected function createClient(array $config)
    {
        $url = Arr::pull($config, 'url');

        $urls = parse_url($url);

        $config['host'] = $urls['host'];
        $config['port'] = $urls['port'];

        switch ($urls['scheme']) {
            case 'http':
                return new HttpClient($this->app, $this->serializerFactory, $config);
            case 'whisper':
                return new WhisperClient($this->app, $this->serializerFactory, $config);
            default:
                throw new InvalidArgumentException('Protocol '.$urls['scheme'].' is not supported for Homer.');
        }
    }