You are here

private function Client::prepareDefaults in Auth0 Single Sign On 8.2

Merges default options into the array.

Parameters

array $options Options to modify by reference:

Return value

array

2 calls to Client::prepareDefaults()
Client::requestAsync in vendor/guzzlehttp/guzzle/src/Client.php
Create and send an asynchronous HTTP request.
Client::sendAsync in vendor/guzzlehttp/guzzle/src/Client.php
Asynchronously send an HTTP request.

File

vendor/guzzlehttp/guzzle/src/Client.php, line 287

Class

Client
@method ResponseInterface get(string|UriInterface $uri, array $options = []) @method ResponseInterface head(string|UriInterface $uri, array $options = []) @method ResponseInterface put(string|UriInterface $uri, array $options = []) @method…

Namespace

GuzzleHttp

Code

private function prepareDefaults(array $options) {
  $defaults = $this->config;
  if (!empty($defaults['headers'])) {

    // Default headers are only added if they are not present.
    $defaults['_conditional'] = $defaults['headers'];
    unset($defaults['headers']);
  }

  // Special handling for headers is required as they are added as
  // conditional headers and as headers passed to a request ctor.
  if (array_key_exists('headers', $options)) {

    // Allows default headers to be unset.
    if ($options['headers'] === null) {
      $defaults['_conditional'] = [];
      unset($options['headers']);
    }
    elseif (!is_array($options['headers'])) {
      throw new \InvalidArgumentException('headers must be an array');
    }
  }

  // Shallow merge defaults underneath options.
  $result = $options + $defaults;

  // Remove null values.
  foreach ($result as $k => $v) {
    if ($v === null) {
      unset($result[$k]);
    }
  }
  return $result;
}