Skip to content

Commit 9b74cf9

Browse files
committed
:octocat:
1 parent 2183b6a commit 9b74cf9

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,17 @@ The following classes contain static methods for use with PSR-7 http message obj
6666
| `recursiveRawurlencode(mixed $data)` | `array\|string` | Recursive [`rawurlencode`](https://www.php.net/manual/en/function.rawurlencode) |
6767

6868
### `MessageUtil`
69-
| method | return | info |
70-
|------------------------------------------------------------------------------------------------------|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
71-
| `getContents(MessageInterface $message)` | `string` | Reads the body content of a `MessageInterface` and makes sure to rewind. |
72-
| `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. |
73-
| `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. |
74-
| `toString(MessageInterface $message)` | `string` | Returns the string representation of an HTTP message. |
75-
| `decompress(MessageInterface $message)` | `string` | Decompresses the message content according to the `Content-Encoding` header (`compress`, `deflate`, `gzip`, `br`, `zstd`) and returns the decompressed data. `br` and `zstd` will throw a `RuntimeException` if the respecive extensions are missing. |
76-
| `setContentLengthHeader(MessageInterface $message)` | `MessageInterface` | Sets a Content-Length header in the given message in case it does not exist and body size is not null |
77-
| `setContentTypeHeader(MessageInterface $message, string $filename = null, string $extension = null)` | `MessageInterface` | Tries to determine the content type from the given values and sets the Content-Type header accordingly, throws if no mime type could be guessed. |
69+
| method | return | info |
70+
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
71+
| `getContents(MessageInterface $message)` | `string` | Reads the body content of a `MessageInterface` and makes sure to rewind. |
72+
| `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. |
73+
| `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. |
74+
| `toString(MessageInterface $message)` | `string` | Returns the string representation of an HTTP message. |
75+
| `decompress(MessageInterface $message)` | `string` | Decompresses the message content according to the `Content-Encoding` header (`compress`, `deflate`, `gzip`, `br`, `zstd`) and returns the decompressed data. `br` and `zstd` will throw a `RuntimeException` if the respecive extensions are missing. |
76+
| `setContentLengthHeader(MessageInterface $message)` | `MessageInterface` | Sets a Content-Length header in the given message in case it does not exist and body size is not null |
77+
| `setContentTypeHeader(MessageInterface $message, string $filename = null, string $extension = null)` | `MessageInterface` | Tries to determine the content type from the given values and sets the Content-Type header accordingly, throws if no mime type could be guessed. |
78+
| `setCookie(ResponseInterface $message, string $name, string $value = null, DateTimeInterface\| DateInterval\|int $expiry = null, string $domain = null, string $path = null, bool $secure = false, bool $httpOnly = false, string $sameSite = null)` | `ResponseInterface` | Adds a Set-Cookie header to a ResponseInterface (convenience) |
79+
| `getCookiesFromHeader(MessageInterface $message)` | `array\|null` | Attempts to extract and parse a cookie from a "Cookie" (user-agent) header |
7880

7981
### `UriUtil`
8082
| method | return | info |
@@ -120,3 +122,18 @@ It provides convenience methods to create server requests, URIs and uploaded fil
120122
| `normalizeFiles(array $files)` | `UploadedFileInterface[]` | Returns an `UploadedFile` instance array. |
121123
| `createUploadedFileFromSpec(array $value)` | `UploadedFileInterface` or `UploadedFileInterface[]` | Creates an UploadedFile instance from a `$_FILES` specification. If the specification represents an array of values, this method will delegate to `normalizeNestedFileSpec()` and return that return value. |
122124
| `normalizeNestedFileSpec(array $files):array` | `array` | Normalizes an array of file specifications. Loops through all nested files and returns a normalized array of `UploadedFileInterface` instances. |
125+
126+
### `Cookie`
127+
Implements a [HTTP cookie](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1)
128+
129+
| method | return | info |
130+
|------------------------------------------------------------------|----------|----------------------------------------------------------------|
131+
| `__construct(string $name, string $value = null)` | - | |
132+
| `__toString()` | `string` | returns the full cookie string to use in a `Set-Cookie` header |
133+
| `withNameAndValue(string $name, string $value)` | `Cookie` | |
134+
| `withExpiry(DateTimeInterface\|DateInterval\|int\|null $expiry)` | `Cookie` | |
135+
| `withDomain(string\|null $domain, bool $punycode = null)` | `Cookie` | |
136+
| `withPath(string\|null $path)` | `Cookie` | |
137+
| `withSecure(bool $secure)` | `Cookie` | |
138+
| `withHttpOnly(bool $httpOnly)` | `Cookie` | |
139+
| `withSameSite(string\|null $sameSite)` | `Cookie` | |

0 commit comments

Comments
 (0)