Snorlax\RestClient::setClient PHP Method

setClient() public method

Sets the client according to the given $config array, following the rules: - If no custom client is given, instantiates a new GuzzleHttp\Client - If an instance of GuzzleHttp\ClientInterface is given, we only pass it through - If a closure is given, it gets executed receiving the parameters given
public setClient ( array $config )
$config array
    public function setClient(array $config)
    {
        if (isset($config['client'])) {
            $config = $config['client'];
        }
        $params = isset($config['params']) ? $config['params'] : [];
        $client = null;
        if (isset($config['custom'])) {
            if (is_callable($config['custom'])) {
                $client = $config['custom']($params);
            } elseif ($config['custom'] instanceof ClientInterface) {
                $client = $config['custom'];
            }
        } else {
            $client = $this->createDefaultClient($params);
        }
        $this->client = $client;
    }