Skip to content

Commit 48be8fa

Browse files
committed
:octocat:
1 parent abfd7a0 commit 48be8fa

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

README.md

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,43 @@ A collection of utilities for use with [PSR-7 Message implementations](https://w
4242
Profit!
4343

4444
## API
45+
The following classes contain static methods for use with PSR-7 http message objects.
4546

46-
### `Header`
47-
The `Header` class contains static methods for use with http request and response headers.
48-
47+
### `HeaderUtil`
4948
method | return | info
5049
------ | ------ | ----
5150
`normalize(array $headers)` | `array` | Normalizes an array of header lines to format `["Name" => "Value (, Value2, Value3, ...)", ...]` An exception is being made for `Set-Cookie`, which holds an array of values for each cookie. For multiple cookies with the same name, only the last value will be kept.
5251

53-
### `Query`
54-
The `Query` class contains static methods for use with http query strings.
55-
52+
### `QueryUtil`
5653
method | return | info
5754
------ | ------ | ----
5855
`cleanParams(iterable $params, int $bool_cast = null, bool $remove_empty = null)` | `array` | Cleans/normalizes an array of query parameters, booleans will be converted according to the given `$bool_cast` constant. By default, booleans will be left as-is (`Query::BOOLEANS_AS_BOOL`) and may result in empty values. If `$remove_empty` is set to true, empty non-boolean and null values will be removed from the array. The `Query` class provides the following constants for `$bool_cast`:<br>`BOOLEANS_AS_BOOL`: unchanged boolean value (default)<br>`BOOLEANS_AS_INT`: integer values 0 or 1<br>`BOOLEANS_AS_STRING`: "true"/"false" strings<br>`BOOLEANS_AS_INT_STRING`: "0"/"1" strings
5956
`build(array $params, int $encoding = null, string $delimiter = null, string $enclosure = null)` | `string` | Builds a query string from an array of key value pairs, similar to [`http_build_query`](https://www.php.net/manual/en/function.http-build-query). Valid values for `$encoding` are `PHP_QUERY_RFC3986` (default) and `PHP_QUERY_RFC1738`, any other integer value will be interpreted as "no encoding" (`Query::NO_ENCODING`).
6057
`merge(string $uri, array $query)` | `string` | Merges additional query parameters into an existing query string.
6158
`parse(string $querystring, int $urlEncoding = null)` | `array` | Parses a query string into an associative array, similar to [`parse_str`](https://www.php.net/manual/en/function.parse-str) (without the inconvenient usage of a by-reference result variable).
59+
`parseUrl(string $url)` | `?array` | UTF-8 aware `\parse_url()` replacement.
60+
61+
### `MessageUtil`
62+
method | return | info
63+
------ | ------ | ----
64+
`decodeJSON(MessageInterface $message, bool $assoc = null)` | mixed | fetches the body of a `MessageInterface` and converts it to a JSON object (`stdClass`) or an associative array if `$assoc` is set to `true` and returns the result.
65+
`decodeXML(MessageInterface $message, bool $assoc = null)` | mixed | fetches the body of a `MessageInterface` and converts it to a `SimpleXMLElement` or an associative array if `$assoc` is set to `true` and returns the result.
66+
`toString(MessageInterface $message)` | `string` | Returns the string representation of an HTTP message.
67+
`decompress(MessageInterface $message)` | `string` | Decompresses the message content according to the `Content-Encoding` header (`compress`, `deflate`, `gzip`, `br`) and returns the decompressed data. For a [`br` (Brotli)](https://en.wikipedia.org/wiki/Brotli) extension see: https://github.com/kjdev/php-ext-brotli
68+
69+
### `UriUtil`
70+
method | return | info
71+
------ | ------ | ----
72+
`isDefaultPort(UriInterface $uri)` | `bool` | Checks whether the `UriInterface` has a port set and if that port is one of the default ports for the given scheme.
73+
`isAbsolute(UriInterface $uri)` | `bool` | Checks Whether the URI is absolute, i.e. it has a scheme.
74+
`isNetworkPathReference(UriInterface $uri)` | `bool` | Checks Whether the URI is a network-path reference.
75+
`isAbsolutePathReference(UriInterface $uri)` | `bool` | Checks Whether the URI is a absolute-path reference.
76+
`isRelativePathReference(UriInterface $uri)` | `bool` | Checks Whether the URI is a relative-path reference.
77+
`withoutQueryValue(UriInterface $uri, string $key)` | `UriInterface` | Removes a specific query string value. Any existing query string values that exactly match the provided `$key` are removed.
78+
`withQueryValue(UriInterface $uri, string $key, string $value = null)` | `UriInterface` | Adds a specific query string value. Any existing query string values that exactly match the provided `$key` are removed and replaced with the given `$key`-`$value` pair. A value of null will set the query string key without a value, e.g. "key" instead of "key=value".
6279

63-
### `Server`
64-
The `Server` object requires a set of [PSR-17 factories](https://www.php-fig.org/psr/psr-17/) on invocation, namely `ServerRequestFactoryInterface`, `UriFactoryInterface`, `UploadedFileFactoryInterface` and `StreamFactoryInterface`.
80+
### `ServerUtil`
81+
The `ServerUtil` object requires a set of [PSR-17 factories](https://www.php-fig.org/psr/psr-17/) on invocation, namely `ServerRequestFactoryInterface`, `UriFactoryInterface`, `UploadedFileFactoryInterface` and `StreamFactoryInterface`.
6582
It provides convenience methods to create server requests, URIs and uploaded files from the [superglobals](https://www.php.net/manual/en/language.variables.superglobals.php).
6683

6784
method | return | info
@@ -80,15 +97,3 @@ function | return | info
8097
`getMimetypeFromExtension(string $extension)` | `?string` | Get the mime type for the given file extension (checks against the constant `chillerlan\HTTP\Utils\MIMETYPES`, a list of mime types from the [apache default config](http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types))
8198
`getMimetypeFromFilename(string $filename)` | `?string` | Get the mime type from a file name
8299
`r_rawurlencode($data)` | mixed | Recursive [`rawurlencode`](https://www.php.net/manual/en/function.rawurlencode)
83-
`get_json(MessageInterface $message, bool $assoc = null)` | mixed | fetches the body of a `MessageInterface` and converts it to a JSON object (`stdClass`) or an associative array if `$assoc` is set to `true` and returns the result.
84-
`get_xml(MessageInterface $message, bool $assoc = null)` | mixed | fetches the body of a `MessageInterface` and converts it to a `SimpleXMLElement` or an associative array if `$assoc` is set to `true` and returns the result.
85-
`message_to_string(MessageInterface $message)` | `string` | Returns the string representation of an HTTP message.
86-
`decompress_content(MessageInterface $message)` | `string` | Decompresses the message content according to the `Content-Encoding` header (`compress`, `deflate`, `gzip`, `br`) and returns the decompressed data. For a [`br` (Brotli)](https://en.wikipedia.org/wiki/Brotli) extension see: https://github.com/kjdev/php-ext-brotli
87-
`uriIsDefaultPort(UriInterface $uri)` | `bool` | Checks whether the `UriInterface` has a port set and if that port is one of the default ports for the given scheme.
88-
`uriIsAbsolute(UriInterface $uri)` | `bool` | Checks Whether the URI is absolute, i.e. it has a scheme.
89-
`uriIsNetworkPathReference(UriInterface $uri)` | `bool` | Checks Whether the URI is a network-path reference.
90-
`uriIsAbsolutePathReference(UriInterface $uri)` | `bool` | Checks Whether the URI is a absolute-path reference.
91-
`uriIsRelativePathReference(UriInterface $uri)` | `bool` | Checks Whether the URI is a relative-path reference.
92-
`uriWithoutQueryValue(UriInterface $uri, string $key)` | `UriInterface` | Removes a specific query string value. Any existing query string values that exactly match the provided `$key` are removed.
93-
`uriWithQueryValue(UriInterface $uri, string $key, string $value = null)` | `UriInterface` | Adds a specific query string value. Any existing query string values that exactly match the provided `$key` are removed and replaced with the given `$key`-`$value` pair. A value of null will set the query string key without a value, e.g. "key" instead of "key=value".
94-
`parseUrl(string $url)` | `?array` | UTF-8 aware \parse_url() replacement.

0 commit comments

Comments
 (0)