Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
GuzzleHttp\Utils Class Reference

Static Public Member Functions

static chooseHandler ()
 Chooses and creates a default handler to use based on the environment.
 
static currentTime ()
 Wrapper for the hrtime() or microtime() functions (depending on the PHP version, one of the two is used)
 
static debugResource ($value=null)
 Returns a debug stream based on the provided variable.
 
static defaultCaBundle ()
 Returns the default cacert bundle for the current system.
 
static defaultUserAgent ()
 Get the default User-Agent string to use with Guzzle.
 
static describeType ($input)
 
static getenv (string $name)
 
static headersFromLines (iterable $lines)
 Parses an array of header lines into an associative array of headers.
 
static idnUriConvert (UriInterface $uri, int $options=0)
 
static isHostInNoProxy (string $host, array $noProxyArray)
 Returns true if the provided host matches any of the no proxy areas.
 
static jsonDecode (string $json, bool $assoc=false, int $depth=512, int $options=0)
 Wrapper for json_decode that throws when an error occurs.
 
static jsonEncode ($value, int $options=0, int $depth=512)
 Wrapper for JSON encoding that throws when an error occurs.
 
static normalizeHeaderKeys (array $headers)
 Creates an associative array of lowercase header names to the actual header casing.
 

Member Function Documentation

◆ chooseHandler()

static GuzzleHttp\Utils::chooseHandler ( )
static

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

The returned handler is not wrapped by any default middlewares.

Return values
callable(\Psr\Http\Message\RequestInterface,array)GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
Exceptions
RuntimeExceptionif no viable Handler is available.

◆ currentTime()

static GuzzleHttp\Utils::currentTime ( )
static

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

Return values
floatUNIX timestamp

◆ debugResource()

static GuzzleHttp\Utils::debugResource ( $value = null)
static

Returns a debug stream based on the provided variable.

Parameters
mixed$valueOptional value
Return values
resource

◆ defaultCaBundle()

static GuzzleHttp\Utils::defaultCaBundle ( )
static

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.

Exceptions
RuntimeExceptionif 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+.

◆ headersFromLines()

static GuzzleHttp\Utils::headersFromLines ( iterable $lines)
static

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

Parameters
iterable$linesHeader lines array of strings in the following format: "Name: Value"

◆ idnUriConvert()

static GuzzleHttp\Utils::idnUriConvert ( UriInterface $uri,
int $options = 0 )
static
Exceptions
InvalidArgumentException

◆ isHostInNoProxy()

static GuzzleHttp\Utils::isHostInNoProxy ( string $host,
array $noProxyArray )
static

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'.
Parameters
string$hostHost to check against the patterns.
string[]$noProxyArrayAn array of host patterns.
Exceptions
InvalidArgumentException

◆ jsonDecode()

static GuzzleHttp\Utils::jsonDecode ( string $json,
bool $assoc = false,
int $depth = 512,
int $options = 0 )
static

Wrapper for json_decode that throws when an error occurs.

Parameters
string$jsonJSON data to parse
bool$assocWhen true, returned objects will be converted into associative arrays.
int$depthUser specified recursion depth.
int$optionsBitmask of JSON decode options.
Return values
object|array|string|int|float|bool|null
Exceptions
InvalidArgumentExceptionif the JSON cannot be decoded.
See also
https://www.php.net/manual/en/function.json-decode.php

◆ jsonEncode()

static GuzzleHttp\Utils::jsonEncode ( $value,
int $options = 0,
int $depth = 512 )
static

Wrapper for JSON encoding that throws when an error occurs.

Parameters
mixed$valueThe value being encoded
int$optionsJSON encode option bitmask
int$depthSet the maximum depth. Must be greater than zero.
Exceptions
InvalidArgumentExceptionif the JSON cannot be encoded.
See also
https://www.php.net/manual/en/function.json-encode.php

The documentation for this class was generated from the following file: