Factory method to create a new Client

The following array keys and values are available options:
- url: Base URL of web service
- token: Storage API token

@param array|Collection $config Configuration data

@return self
977073
public static function factory($config = [])
    {
        $default = [
            'url' => 'https://syrup.keboola.com/gooddata-writer'
        ];
        $required = ['token'];
        $config = Collection::fromConfig($config, $default, $required);
        $config['request.options'] = [
            'headers' => [
                'X-StorageApi-Token' => $config->get('token')
            ],
            'config' => [
                'curl' => [
                    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0
                ]

            ]
        ];

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

        // Attach a service description to the client
        $description = ServiceDescription::factory(__DIR__ . '/service.json');
        $client->setDescription($description);

        $client->setBaseUrl($config->get('url'));

        // Setup exponential backoff
        // 503 retry always, other errors five times
        $backoffPlugin = new BackoffPlugin(new TruncatedBackoffStrategy(
            5,
            new HttpBackoffStrategy(
                null,
                new CurlBackoffStrategy(
                    null,
                    new ExponentialBackoffStrategy()
                )
            )
        ));
        $client->addSubscriber($backoffPlugin);

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

        $client = new Client();

        return new GitterGateway($client, $config);
    }
814036
protected function makeBaseClient($config)
    {
        $parameters = $this->getParameters($config);

        $client = new Client($parameters);

        $this->attachSubscribers($client);

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

        $client = new Client();

        return new PushoverGateway($client, $config);
    }
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']);
	}
965729
protected function getClient(array $config): Client
    {
        $client = Client::create($config['url']);

        $client->authenticate(
            $config['token'],
            array_get($config, 'method', Client::AUTH_URL_TOKEN),
            array_get($config, 'sudo', null)
        );

        return $client;
    }
492132
public static function create($config)
    {

        $clientBuilder = ClientBuilder::create();

        if (!empty($config['handler'])) {
            $clientBuilder->setHandler($config['handler']);
        }

        $clientBuilder->setHosts($config["servers"]);

        $clientBuilder = self::configureLogging($clientBuilder,$config);

        $query = new Query($clientBuilder->build());

        if (array_key_exists("index", $config) and $config["index"] != "") {
            $query->index($config["index"]);
        }

        return $query;
    }
1191699
public function createService(Config $config)
    {
        $options = $config->getCacheOptions();

        $storage = new FileSystem($options->getStorageOptions());

        return $storage;
    }
348803
public static function newInstance($config)
	{

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

		$gateway = new self();
		$gateway->setConfig($config);

		return $gateway;

	}
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;
    }
147543
public static function factory(array $config = [])
    {
        // Swagger docs URI is required
        $required = ['base_uri'];
        if ($missing = array_diff($required, array_keys($config))) {
            throw new \InvalidArgumentException('Config is missing the following keys: '.implode(', ', $missing));
        }

        $serviceConfig = json_decode(file_get_contents(__DIR__.'/Resources/service.json'), true);
        // allow override of base_uri after it's been set by service description
        if (isset($config['base_uri'])) {
            $serviceConfig['baseUri'] = $config['base_uri'];
        }
        // describe service from included config file.
        $description = new Description($serviceConfig);

        // Prefix Loco identifier to user agent string
        $config['headers']['User-Agent'] = $description->getName().'/'.$description->getApiVersion()
            .' '.\GuzzleHttp\default_user_agent();

        // Create a new instance of HTTP Client
        $client = new Client($config);

        // Create a new instance of self
        return new self(
            $client,
            $description,
            null,
            new Deserializer($description, true)
        );
    }
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.');
        }
    }
146568
public static function factory($config = array())
	{
		$default = array();
		$required = array('base_url');
		$config = Inspector::prepareConfig($config, $default, $required);
		$client = new self($config->get('base_url'), $config->get('token'));
		$client->setConfig($config);
		$client->getEventDispatcher()->addSubscriber(new AuthenticationObserver());
		return $client;
	}
726558
public static function factory($config, array $options = array())
    {
        // @codeCoverageIgnoreStart
        if (!self::$descriptionLoader) {
            self::$descriptionLoader = new ServiceDescriptionLoader();
        }
        // @codeCoverageIgnoreEnd

        return self::$descriptionLoader->load($config, $options);
    }
20576
public static function create(ConfigFactoryInterface $config) {
    // Get broker url from config.
    $settings = $config->get(IslandoraSettingsForm::CONFIG_NAME);
    $brokerUrl = $settings->get(IslandoraSettingsForm::BROKER_URL);

    // Try a sensible default if one hasn't been configured.
    if (empty($brokerUrl)) {
      $brokerUrl = "tcp://localhost:61613";
    }

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

        return $this->getClient($config);
    }
823939
public static function create(Config $config)
    {
        if (php_sapi_name() === 'cli' || !(self::$instance instanceof self)) {
            self::$instance = new self($config);
        }

        return self::$instance;
    }