Copied!
CloneableFinalInstantiable
Methods
public static chooseHandler() : callable
 

Chooses and creates a default handler to use based on the environment.

The returned handler is not wrapped by any default middlewares.

  • return callable Returns the best handler for the given system.
  • throws \RuntimeException if no viable Handler is available.
public static currentTime() : float
 

Wrapper for the hrtime() or microtime() functions (depending on the PHP version, one of the two is used)

  • return float UNIX timestamp
  • internal
public static debugResource( $value = NULL)
 

Returns a debug stream based on the provided variable.

  • param mixed $value Optional value
  • return resource
public static defaultCaBundle() : string
 

Returns the default cacert bundle for the current system.

First, the openssl.cafile and curl.cainfo php.ini settings are checked. If those settings are not configured, then the common locations for bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X and Windows are checked. If any of these file locations are found on disk, they will be utilized.

Note: the result of this function is cached for subsequent calls.

  • throws \RuntimeException if no bundle can be found.
  • deprecated Utils::defaultCaBundle will be removed in guzzlehttp/guzzle:8.0. This method is not needed in PHP 5.6+.
public static defaultUserAgent() : string
 

Get the default User-Agent string to use with Guzzle.

public static describeType( $input) : string
 

Debug function used to describe the provided value type and class.

  • param mixed $input
  • return string Returns a string containing the type of the variable and if a class is provided, the class name.
public static getenv(string $name) : ?string
 
  • internal
public static headersFromLines(iterable $lines) : array
 

Parses an array of header lines into an associative array of headers.

  • param iterable $lines Header lines array of strings in the following format: "Name: Value"
public static idnUriConvert(Psr\Http\Message\UriInterface $uri, int $options = 0) : Psr\Http\Message\UriInterface
 
  • throws \InvalidArgumentException
  • internal
public static isHostInNoProxy(string $host, array $noProxyArray) : bool
 

Returns true if the provided host matches any of the no proxy areas.

This method will strip a port from the host if it is present. Each pattern can be matched with an exact match (e.g., "foo.com" == "foo.com") or a partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" == "baz.foo.com", but ".foo.com" != "foo.com").

Areas are matched in the following cases:

  1. "*" (without quotes) always matches any hosts.
  2. An exact match.
  3. The area starts with "." and the area is the last part of the host. e.g. '.mit.edu' will match any host that ends with '.mit.edu'.
  • param string $host Host to check against the patterns.
  • param string[] $noProxyArray An array of host patterns.
  • throws \InvalidArgumentException
public static jsonDecode(string $json, bool $assoc = false, int $depth = 512, int $options = 0)
 

Wrapper for json_decode that throws when an error occurs.

  • param string $json JSON data to parse
  • param bool $assoc When true, returned objects will be converted into associative arrays.
  • param int $depth User specified recursion depth.
  • param int $options Bitmask of JSON decode options.
  • return object|array|string|int|float|bool|null
  • throws \InvalidArgumentException if the JSON cannot be decoded.
  • see https://www.php.net/manual/en/function.json-decode.php
public static jsonEncode( $value, int $options = 0, int $depth = 512) : string
 

Wrapper for JSON encoding that throws when an error occurs.

  • param mixed $value The value being encoded
  • param int $options JSON encode option bitmask
  • param int $depth Set the maximum depth. Must be greater than zero.
  • throws \InvalidArgumentException if the JSON cannot be encoded.
  • see https://www.php.net/manual/en/function.json-encode.php
public static normalizeHeaderKeys(array $headers) : array
 

Creates an associative array of lowercase header names to the actual header casing.

Methods
private static idnToAsci(string $domain, int $options, ?array $info = [])
 
  • return string|false
Methods
public static chooseHandler() : callable
 

Chooses and creates a default handler to use based on the environment.

The returned handler is not wrapped by any default middlewares.

  • return callable Returns the best handler for the given system.
  • throws \RuntimeException if no viable Handler is available.
public static currentTime() : float
 

Wrapper for the hrtime() or microtime() functions (depending on the PHP version, one of the two is used)

  • return float UNIX timestamp
  • internal
public static debugResource( $value = NULL)
 

Returns a debug stream based on the provided variable.

  • param mixed $value Optional value
  • return resource
public static defaultCaBundle() : string
 

Returns the default cacert bundle for the current system.

First, the openssl.cafile and curl.cainfo php.ini settings are checked. If those settings are not configured, then the common locations for bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X and Windows are checked. If any of these file locations are found on disk, they will be utilized.

Note: the result of this function is cached for subsequent calls.

  • throws \RuntimeException if no bundle can be found.
  • deprecated Utils::defaultCaBundle will be removed in guzzlehttp/guzzle:8.0. This method is not needed in PHP 5.6+.
public static defaultUserAgent() : string
 

Get the default User-Agent string to use with Guzzle.

public static describeType( $input) : string
 

Debug function used to describe the provided value type and class.

  • param mixed $input
  • return string Returns a string containing the type of the variable and if a class is provided, the class name.
public static getenv(string $name) : ?string
 
  • internal
public static headersFromLines(iterable $lines) : array
 

Parses an array of header lines into an associative array of headers.

  • param iterable $lines Header lines array of strings in the following format: "Name: Value"
private static idnToAsci(string $domain, int $options, ?array $info = [])
 
  • return string|false
public static idnUriConvert(Psr\Http\Message\UriInterface $uri, int $options = 0) : Psr\Http\Message\UriInterface
 
  • throws \InvalidArgumentException
  • internal
public static isHostInNoProxy(string $host, array $noProxyArray) : bool
 

Returns true if the provided host matches any of the no proxy areas.

This method will strip a port from the host if it is present. Each pattern can be matched with an exact match (e.g., "foo.com" == "foo.com") or a partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" == "baz.foo.com", but ".foo.com" != "foo.com").

Areas are matched in the following cases:

  1. "*" (without quotes) always matches any hosts.
  2. An exact match.
  3. The area starts with "." and the area is the last part of the host. e.g. '.mit.edu' will match any host that ends with '.mit.edu'.
  • param string $host Host to check against the patterns.
  • param string[] $noProxyArray An array of host patterns.
  • throws \InvalidArgumentException
public static jsonDecode(string $json, bool $assoc = false, int $depth = 512, int $options = 0)
 

Wrapper for json_decode that throws when an error occurs.

  • param string $json JSON data to parse
  • param bool $assoc When true, returned objects will be converted into associative arrays.
  • param int $depth User specified recursion depth.
  • param int $options Bitmask of JSON decode options.
  • return object|array|string|int|float|bool|null
  • throws \InvalidArgumentException if the JSON cannot be decoded.
  • see https://www.php.net/manual/en/function.json-decode.php
public static jsonEncode( $value, int $options = 0, int $depth = 512) : string
 

Wrapper for JSON encoding that throws when an error occurs.

  • param mixed $value The value being encoded
  • param int $options JSON encode option bitmask
  • param int $depth Set the maximum depth. Must be greater than zero.
  • throws \InvalidArgumentException if the JSON cannot be encoded.
  • see https://www.php.net/manual/en/function.json-encode.php
public static normalizeHeaderKeys(array $headers) : array
 

Creates an associative array of lowercase header names to the actual header casing.

© 2025 Bruce Wells
Search Namespaces \ Classes
Configuration