Utils
in package
Table of Contents
- chooseHandler() : callable
- Chooses and creates a default handler to use based on the environment.
- debugResource() : resource
- Returns a debug stream based on the provided variable.
- defaultCaBundle() : string
- Returns the default cacert bundle for the current system.
- defaultUserAgent() : string
- Get the default User-Agent string to use with Guzzle.
- describeType() : string
- Debug function used to describe the provided value type and class.
- headersFromLines() : array<string|int, mixed>
- Parses an array of header lines into an associative array of headers.
- isHostInNoProxy() : bool
- Returns true if the provided host matches any of the no proxy areas.
- jsonDecode() : object|array<string|int, mixed>|string|int|float|bool|null
- Wrapper for json_decode that throws when an error occurs.
- jsonEncode() : string
- Wrapper for JSON encoding that throws when an error occurs.
- normalizeHeaderKeys() : array<string|int, mixed>
- Creates an associative array of lowercase header names to the actual header casing.
- idnToAsci() : string|false
Methods
chooseHandler()
Chooses and creates a default handler to use based on the environment.
public
static chooseHandler() : callable
The returned handler is not wrapped by any default middlewares.
Tags
Return values
callable —debugResource()
Returns a debug stream based on the provided variable.
public
static debugResource([mixed $value = null ]) : resource
Parameters
- $value : mixed = null
-
Optional value
Return values
resource —defaultCaBundle()
Returns the default cacert bundle for the current system.
public
static defaultCaBundle() : string
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.
Tags
Return values
string —defaultUserAgent()
Get the default User-Agent string to use with Guzzle.
public
static defaultUserAgent() : string
Return values
string —describeType()
Debug function used to describe the provided value type and class.
public
static describeType(mixed $input) : string
Parameters
- $input : mixed
Return values
string —Returns a string containing the type of the variable and if a class is provided, the class name.
headersFromLines()
Parses an array of header lines into an associative array of headers.
public
static headersFromLines(iteratable<string|int, mixed> $lines) : array<string|int, mixed>
Parameters
- $lines : iteratable<string|int, mixed>
-
Header lines array of strings in the following format: "Name: Value"
Return values
array<string|int, mixed> —isHostInNoProxy()
Returns true if the provided host matches any of the no proxy areas.
public
static isHostInNoProxy(string $host, array<string|int, string> $noProxyArray) : bool
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:
- "*" (without quotes) always matches any hosts.
- An exact match.
- 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
- $host : string
-
Host to check against the patterns.
- $noProxyArray : array<string|int, string>
-
An array of host patterns.
Tags
Return values
bool —jsonDecode()
Wrapper for json_decode that throws when an error occurs.
public
static jsonDecode(string $json[, bool $assoc = false ][, int $depth = 512 ], int $options) : object|array<string|int, mixed>|string|int|float|bool|null
Parameters
- $json : string
-
JSON data to parse
- $assoc : bool = false
-
When true, returned objects will be converted into associative arrays.
- $depth : int = 512
-
User specified recursion depth.
- $options : int
-
Bitmask of JSON decode options.
Tags
Return values
object|array<string|int, mixed>|string|int|float|bool|null —jsonEncode()
Wrapper for JSON encoding that throws when an error occurs.
public
static jsonEncode(mixed $value, int $options[, int $depth = 512 ]) : string
Parameters
- $value : mixed
-
The value being encoded
- $options : int
-
JSON encode option bitmask
- $depth : int = 512
-
Set the maximum depth. Must be greater than zero.
Tags
Return values
string —normalizeHeaderKeys()
Creates an associative array of lowercase header names to the actual header casing.
public
static normalizeHeaderKeys(array<string|int, mixed> $headers) : array<string|int, mixed>
Parameters
- $headers : array<string|int, mixed>
Return values
array<string|int, mixed> —idnToAsci()
private
static idnToAsci(string $domain, int $options[, array<string|int, mixed>|null &$info = [] ]) : string|false
Parameters
- $domain : string
- $options : int
- $info : array<string|int, mixed>|null = []