Documentation

functions.php

Table of Contents

Functions

uri_template()  : string
Expands a URI template
describe_type()  : string
Debug function used to describe the provided value type and class.
headers_from_lines()  : array<string|int, mixed>
Parses an array of header lines into an associative array of headers.
debug_resource()  : resource
Returns a debug stream based on the provided variable.
choose_handler()  : callable
Chooses and creates a default handler to use based on the environment.
default_user_agent()  : string
Get the default User-Agent string to use with Guzzle
default_ca_bundle()  : string
Returns the default cacert bundle for the current system.
normalize_header_keys()  : array<string|int, mixed>
Creates an associative array of lowercase header names to the actual header casing.
is_host_in_noproxy()  : bool
Returns true if the provided host matches any of the no proxy areas.
json_decode()  : mixed
Wrapper for json_decode that throws when an error occurs.
json_encode()  : string
Wrapper for JSON encoding that throws when an error occurs.

Functions

uri_template()

Expands a URI template

uri_template(string $template, array<string|int, mixed> $variables) : string
Parameters
$template : string

URI template

$variables : array<string|int, mixed>

Template variables

Return values
string

describe_type()

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

describe_type(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.

headers_from_lines()

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

headers_from_lines(iterable<string|int, mixed> $lines) : array<string|int, mixed>
Parameters
$lines : iterable<string|int, mixed>

Header lines array of strings in the following format: "Name: Value"

Return values
array<string|int, mixed>

debug_resource()

Returns a debug stream based on the provided variable.

debug_resource([mixed $value = null ]) : resource
Parameters
$value : mixed = null

Optional value

Return values
resource

choose_handler()

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

choose_handler() : callable

The returned handler is not wrapped by any default middlewares.

Tags
throws
RuntimeException

if no viable Handler is available.

Return values
callable

Returns the best handler for the given system.

default_user_agent()

Get the default User-Agent string to use with Guzzle

default_user_agent() : string
Return values
string

default_ca_bundle()

Returns the default cacert bundle for the current system.

default_ca_bundle() : 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
throws
RuntimeException

if no bundle can be found.

Return values
string

normalize_header_keys()

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

normalize_header_keys(array<string|int, mixed> $headers) : array<string|int, mixed>
Parameters
$headers : array<string|int, mixed>
Return values
array<string|int, mixed>

is_host_in_noproxy()

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

is_host_in_noproxy(string $host, array<string|int, mixed> $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:

  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
$host : string

Host to check against the patterns.

$noProxyArray : array<string|int, mixed>

An array of host patterns.

Return values
bool

json_decode()

Wrapper for json_decode that throws when an error occurs.

json_decode(string $json[, bool $assoc = false ][, int $depth = 512 ][, int $options = 0 ]) : mixed
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 = 0

Bitmask of JSON decode options.

Tags
throws
InvalidArgumentException

if the JSON cannot be decoded.

link
http://www.php.net/manual/en/function.json-decode.php

json_encode()

Wrapper for JSON encoding that throws when an error occurs.

json_encode(mixed $value[, int $options = 0 ][, int $depth = 512 ]) : string
Parameters
$value : mixed

The value being encoded

$options : int = 0

JSON encode option bitmask

$depth : int = 512

Set the maximum depth. Must be greater than zero.

Tags
throws
InvalidArgumentException

if the JSON cannot be encoded.

link
http://www.php.net/manual/en/function.json-encode.php
Return values
string

        
On this page

Search results