Basic factory method to create a new client. Extend this method in subclasses to build more complex clients.

@param array|Collection $config Configuration data

@return Client
428828
public static function factory($config = array())
    {
        $defaults = array();

        $required = array(
            'base_url',
            'login',
            'password'
        );

        $config = Collection::fromConfig($config, $defaults, $required);

        $client = new self($config['base_url'], $config);

        return $client;
    }
1165496
public static function factory($config = array())
    {
        $required = array(
            'base_url',
            'username',
            'password',
        );

        $defaults = array(
            'base_url' => self::BASE_URL,
            'base_path' => self::BASE_PATH,
        );

        // Instantiate the Acquia Search plugin.
        $config = Collection::fromConfig($config, $defaults, $required);
        $client = new static($config->get('base_url'), $config);
        $client->setDefaultHeaders(array(
            'Content-Type' => 'application/json; charset=utf-8',
        ));

        // Attach the Acquia Search plugin to the client.
        $plugin = new CloudApiAuthPlugin($config->get('username'), $config->get('password'));
        $client->addSubscriber($plugin);

        return $client;
    }
70966
protected function getBuilder(array $config)
    {
        $builder = new ClientBuilder();

        if ($backoff = array_get($config, 'backoff')) {
            $builder->addPlugin(new RetryPlugin(['retries' => $backoff === true ? 2 : $backoff]));
        }

        if ($this->cache && class_exists(CacheItemPool::class) && $cache = array_get($config, 'cache')) {
            $builder->addCache(new CacheItemPool($this->cache->store($cache === true ? null : $cache)));
        }

        return $builder;
    }
241461
private function buildClient(array $config)
    {
        $client = ClientBuilder::create()
            ->setHosts($config['hosts']);

        if (isset($config['retries'])) {
            $client->setRetries($config['retries']);
        }

        if (isset($config['logging']) and $config['logging']['enabled'] == true) {
            $logger = ClientBuilder::defaultLogger($config['logging']['path'], $config['logging']['level']);
            $client->setLogger($logger);
        }

        return $client->build();
    }
137866
private static function buildClient(array $config = []): GuzzleClient
    {
        $handlerStack = new HandlerStack(\GuzzleHttp\choose_handler());
        $handlerStack->push(Middleware::prepareBody(), 'prepare_body');
        $config = array_merge(['handler' => $handlerStack], $config);

        return new GuzzleClient($config);
    }
726558
public static function factory($config, array $options = array())
    {
        // @codeCoverageIgnoreStart
        if (!self::$descriptionLoader) {
            self::$descriptionLoader = new ServiceDescriptionLoader();
        }
        // @codeCoverageIgnoreEnd

        return self::$descriptionLoader->load($config, $options);
    }
815805
public static function factory($config = array())
    {
        $default = array(
            'base_url' => 'https://bitpay.com/api',
        );

        $required = array(
            'apiKey'
        );

        $config = Collection::fromConfig($config, $default, $required);

        $client = new self($config->get('base_url'), $config);
        $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
        $client->setDefaultOption(
            'auth',
            array(
                $config['apiKey'],
                '',
                'Basic'
            )
        );

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

        return $this->createConnection(
            $config['driver'], $pdo, $config['database'], $config['prefix'], $config
        );
    }
461088
public static function factory($config = array())
    {
        $default = array(
            'base_url' => 'https://api.runkeeper.com',
            'logger' => FALSE,
        );
        $required = array('base_url');

        $config = Collection::fromConfig($config, $default, $required);

        $client = new self($config->get('base_url'));
        $client->setConfig($config);

        $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));

        // Set the iterator resource factory based on the provided iterators config
        $clientClass = get_class();
        $prefix = substr($clientClass, 0, strrpos($clientClass, '\\'));
        $client->setResourceIteratorFactory(
            new HealthGraphIteratorFactory(array("{$prefix}\\Common\\Iterator"))
        );

        if ($config->get('logger')) {
            $adapter = new \Guzzle\Log\PsrLogAdapter($config->get('logger'));
            $logPlugin = new \Guzzle\Plugin\Log\LogPlugin(
                $adapter,
                \Guzzle\Log\MessageFormatter::DEBUG_FORMAT
            );
            $client->addSubscriber($logPlugin);
        }

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

        $client = new Client();

        return new GitterGateway($client, $config);
    }
1208451
public function make(array $config): SearchClient
    {
        $config = $this->getConfig($config);

        return $this->getClient($config);
    }
257880
public function fromConfig(array $config)
    {
        if ($this->env === 'dev' && php_sapi_name() !== 'cli') {
            //for performance reason only in dev mode: https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_configuration.html#enabling_logger
            $config['Tracer'] = $this->logger;
        }
        $config['connectionPool'] = SniffingConnectionPool::class;

        return ClientBuilder::fromConfig($config);
    }
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;
    }
1169618
public static function factory($config = array())
    {
        $required = array('base_url');
        $config = Collection::fromConfig($config, array(), $required);

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

        $cookiePlugin = new CookiePlugin(new ArrayCookieJar());
        $client->addSubscriber($cookiePlugin);

        $client->setConfig($config);
        $client->setUserAgent('addwiki-guzzle-mediawiki-client');
        $client->setDescription(ServiceDescription::factory( dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'mediawiki.json'));

        return $client;
    }
546741
public function connect(array $config)
	{
		$sqsConfig = array_only($config, array('key', 'secret', 'region', 'default_cache_config'));

		$sqs = SqsClient::factory($sqsConfig);

		return new SqsQueue($sqs, $config['queue']);
	}
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
            )
        );
    }
1354035
public function make(array $config)
    {
        Arr::requires($config, ['endpoint']);

        $client = new Client();

        return new WebhookGateway($client, $config);
    }