serve/vendor/guzzlehttp/psr7/srcfunctions.php

Functions

str()

str(\Psr\Http\Message\MessageInterface  $message) : string

Returns the string representation of an HTTP message.

Parameters

\Psr\Http\Message\MessageInterface $message

Message to convert to a string.

Returns

string —

uri_for()

uri_for(string|\Psr\Http\Message\UriInterface  $uri) : \Psr\Http\Message\UriInterface

Returns a UriInterface for the given value.

This function accepts a string or UriInterface and returns a UriInterface for the given value. If the value is already a UriInterface, it is returned as-is.

Parameters

string|\Psr\Http\Message\UriInterface $uri

Throws

\InvalidArgumentException

Returns

\Psr\Http\Message\UriInterface —

stream_for()

stream_for(resource|string|int|float|bool|\Psr\Http\Message\StreamInterface|callable|\Iterator|null  $resource = '', array  $options = []) : \Psr\Http\Message\StreamInterface

Create a new stream based on the input type.

Options is an associative array that can contain the following keys:

  • metadata: Array of custom metadata.
  • size: Size of the stream.

This method accepts the following $resource types:

  • Psr\Http\Message\StreamInterface: Returns the value as-is.
  • string: Creates a stream object that uses the given string as the contents.
  • resource: Creates a stream object that wraps the given PHP stream resource.
  • Iterator: If the provided value implements Iterator, then a read-only stream object will be created that wraps the given iterable. Each time the stream is read from, data from the iterator will fill a buffer and will be continuously called until the buffer is equal to the requested read size. Subsequent read calls will first read from the buffer and then call next on the underlying iterator until it is exhausted.
  • object with __toString(): If the object has the __toString() method, the object will be cast to a string and then a stream will be returned that uses the string value.
  • NULL: When null is passed, an empty stream object is returned.
  • callable When a callable is passed, a read-only stream object will be created that invokes the given callable. The callable is invoked with the number of suggested bytes to read. The callable can return any number of bytes, but MUST return false when there is no more data to return. The stream object that wraps the callable will invoke the callable until the number of requested bytes are available. Any additional bytes will be buffered and used in subsequent reads.

Parameters

resource|string|int|float|bool|\Psr\Http\Message\StreamInterface|callable|\Iterator|null $resource

Entity body data

array $options

Additional options

Throws

\InvalidArgumentException

if the $resource arg is not valid.

Returns

\Psr\Http\Message\StreamInterface —

parse_header()

parse_header(string|array  $header) : array

Parse an array of header values containing ";" separated data into an array of associative arrays representing the header key value pair data of the header. When a parameter does not contain a value, but just contains a key, this function will inject a key with a '' string value.

Parameters

string|array $header

Header to parse into components.

Returns

array —

Returns the parsed header values.

normalize_header()

normalize_header(string|array  $header) : array

Converts an array of header values that may contain comma separated headers into an array of headers with no comma separated values.

Parameters

string|array $header

Header to normalize.

Returns

array —

Returns the normalized header field values.

modify_request()

modify_request(\Psr\Http\Message\RequestInterface  $request, array  $changes) : \Psr\Http\Message\RequestInterface

Clone and modify a request with the given changes.

This method is useful for reducing the number of clones needed to mutate a message.

The changes can be one of:

  • method: (string) Changes the HTTP method.
  • set_headers: (array) Sets the given headers.
  • remove_headers: (array) Remove the given headers.
  • body: (mixed) Sets the given body.
  • uri: (UriInterface) Set the URI.
  • query: (string) Set the query string value of the URI.
  • version: (string) Set the protocol version.

Parameters

\Psr\Http\Message\RequestInterface $request

Request to clone and modify.

array $changes

Changes to apply.

Returns

\Psr\Http\Message\RequestInterface —

rewind_body()

rewind_body(\Psr\Http\Message\MessageInterface  $message) : mixed

Attempts to rewind a message body and throws an exception on failure.

The body of the message will only be rewound if a call to tell() returns a value other than 0.

Parameters

\Psr\Http\Message\MessageInterface $message

Message to rewind

Throws

\RuntimeException

Returns

mixed —

try_fopen()

try_fopen(string  $filename, string  $mode) : resource

Safely opens a PHP stream resource using a filename.

When fopen fails, PHP normally raises a warning. This function adds an error handler that checks for errors and throws an exception instead.

Parameters

string $filename

File to open

string $mode

Mode used to open the file

Throws

\RuntimeException

if the file cannot be opened

Returns

resource —

copy_to_string()

copy_to_string(\Psr\Http\Message\StreamInterface  $stream, int  $maxLen = -1) : string

Copy the contents of a stream into a string until the given number of bytes have been read.

Parameters

\Psr\Http\Message\StreamInterface $stream

Stream to read

int $maxLen

Maximum number of bytes to read. Pass -1 to read the entire stream.

Throws

\RuntimeException

on error.

Returns

string —

copy_to_stream()

copy_to_stream(\Psr\Http\Message\StreamInterface  $source, \Psr\Http\Message\StreamInterface  $dest, int  $maxLen = -1) : mixed

Copy the contents of a stream into another stream until the given number of bytes have been read.

Parameters

\Psr\Http\Message\StreamInterface $source

Stream to read from

\Psr\Http\Message\StreamInterface $dest

Stream to write to

int $maxLen

Maximum number of bytes to read. Pass -1 to read the entire stream.

Throws

\RuntimeException

on error.

Returns

mixed —

hash()

hash(\Psr\Http\Message\StreamInterface  $stream, string  $algo, bool  $rawOutput = false) : string

Calculate a hash of a stream.

This method reads the entire stream to calculate a rolling hash, based on PHP's hash_init functions.

Parameters

\Psr\Http\Message\StreamInterface $stream

Stream to calculate the hash for

string $algo

Hash algorithm (e.g. md5, crc32, etc)

bool $rawOutput

Whether or not to use raw output

Throws

\RuntimeException

on error.

Returns

string —

Returns the hash of the stream

readline()

readline(\Psr\Http\Message\StreamInterface  $stream, int|null  $maxLength = null) : string

Read a line from the stream up to the maximum allowed buffer length.

Parameters

\Psr\Http\Message\StreamInterface $stream

Stream to read from

int|null $maxLength

Maximum buffer length

Returns

string —

parse_request()

parse_request(string  $message) : \GuzzleHttp\Psr7\Request

Parses a request message string into a request object.

Parameters

string $message

Request message string.

Returns

\GuzzleHttp\Psr7\Request —

parse_response()

parse_response(string  $message) : \GuzzleHttp\Psr7\Response

Parses a response message string into a response object.

Parameters

string $message

Response message string.

Returns

\GuzzleHttp\Psr7\Response —

parse_query()

parse_query(string  $str, int|bool  $urlEncoding = true) : array

Parse a query string into an associative array.

If multiple values are found for the same key, the value of that key value pair will become an array. This function does not parse nested PHP style arrays into an associative array (e.g., foo[a]=1&foo[b]=2 will be parsed into ['foo[a]' => '1', 'foo[b]' => '2']).

Parameters

string $str

Query string to parse

int|bool $urlEncoding

How the query string is encoded

Returns

array —

build_query()

build_query(array  $params, int|false  $encoding = PHP_QUERY_RFC3986) : string

Build a query string from an array of key value pairs.

This function can use the return value of parse_query() to build a query string. This function does not modify the provided keys when an array is encountered (like http_build_query() would).

Parameters

array $params

Query string parameters.

int|false $encoding

Set to false to not encode, PHP_QUERY_RFC3986 to encode using RFC3986, or PHP_QUERY_RFC1738 to encode using RFC1738.

Returns

string —

mimetype_from_filename()

mimetype_from_filename(string  $filename) : string|null

Determines the mimetype of a file by looking at its extension.

Parameters

string $filename

Returns

string|null —

mimetype_from_extension()

mimetype_from_extension( $extension) : string|null

Maps a file extensions to a mimetype.

Parameters

$extension

string The file extension.

Returns

string|null —

get_message_body_summary()

get_message_body_summary(\Psr\Http\Message\MessageInterface  $message, int  $truncateAt = 120) : string|null

Get a short summary of the message body.

Will return null if the response is not printable.

Parameters

\Psr\Http\Message\MessageInterface $message

The message to get the body summary

int $truncateAt

The maximum allowed size of the summary

Returns

string|null —