Methods |
public
|
__construct($items = [])
|
#
|
public
static
|
from(
Arrayable<string, string[]|string>|iterable<string, string[]|string>|MessageInterface|string $headersOrPayload,
): static
|
#
|
public
|
addLine(string $line, bool $strict = false)
Parse and apply a header field line or continuation thereof
Parse and apply a header field line or continuation thereof
To initialise an instance from an HTTP stream or message, call this
method once per field line after the request or status line, including
the CRLF sequence at the end of each line. After receiving an empty line
("\r\n" ), {@see hasEmptyLine()} returns true , and any headers
received via {@see addLine()} are applied as trailers.
Parameters
$strict |
If true , strict [RFC9112] compliance is enforced.
|
Implements
|
#
|
public
|
hasEmptyLine(): bool
Check if an empty line has been received via addLine()
Check if an empty line has been received via addLine()
Implements
|
#
|
public
|
hasBadWhitespace(): bool
Check if a line with bad whitespace has been received via addLine()
Check if a line with bad whitespace has been received via addLine()
Implements
|
#
|
public
|
hasObsoleteLineFolding(): bool
Check if obsolete line folding has been received via addLine()
Check if obsolete line folding has been received via addLine()
Implements
|
#
|
public
|
addValue($key, $value)
Apply a value to a header, preserving any existing values
Apply a value to a header, preserving any existing values
Implements
|
#
|
public
|
set($key, $value)
Add or replace an item with a given key
Add or replace an item with a given key
Implements
|
#
|
public
|
unset($key)
Remove an item with a given key
Remove an item with a given key
Implements
|
#
|
public
|
merge($items, bool $preserveValues = false)
Merge the collection with the given items
Merge the collection with the given items
Implements
|
#
|
public
|
sort()
Sort items in the collection
Sort items in the collection
Implements
|
#
|
public
|
reverse()
Reverse the order of items in the collection
Reverse the order of items in the collection
Implements
|
#
|
public
|
map(callable $callback, int $mode = CollectionInterface::CALLBACK_USE_VALUE)
Pass each item in the collection to a callback and populate a new
collection with its return values
Pass each item in the collection to a callback and populate a new
collection with its return values
Implements
|
#
|
public
|
filter(callable $callback, int $mode = CollectionInterface::CALLBACK_USE_VALUE)
Reduce the collection to items that satisfy a callback
Reduce the collection to items that satisfy a callback
Implements
|
#
|
public
|
only(array $keys)
Reduce the collection to items with keys in an array
Reduce the collection to items with keys in an array
Implements
|
#
|
public
|
onlyIn(array $index)
Reduce the collection to items with keys in an index
Reduce the collection to items with keys in an index
Implements
|
#
|
public
|
except(array $keys)
Reduce the collection to items with keys not in an array
Reduce the collection to items with keys not in an array
Implements
|
#
|
public
|
exceptIn(array $index)
Reduce the collection to items with keys not in an index
Reduce the collection to items with keys not in an index
Implements
|
#
|
public
|
slice(int $offset, ?int $length = null)
Extract a slice of the collection
Extract a slice of the collection
Implements
|
#
|
public
|
pop(&$last = null)
Pop an item off the end of the collection
Pop an item off the end of the collection
Parameters
$last |
Receives the value removed from the collection,
or null if the collection is empty.
|
Implements
|
#
|
public
|
shift(&$first = null)
Shift an item off the beginning of the collection
Shift an item off the beginning of the collection
Parameters
$first |
Receives the value removed from the collection,
or null if the collection is empty.
|
Implements
|
#
|
public
|
authorize(CredentialInterface $credential, string $headerName = Headers::HEADER_AUTHORIZATION)
Apply a credential to a header
Apply a credential to a header
Implements
|
#
|
public
|
normalise()
Move the "Host" header to the start of the collection if present
Move the "Host" header to the start of the collection if present
Implements
|
#
|
public
|
trailers()
Reduce the collection to headers received after the message body
Reduce the collection to headers received after the message body
Implements
|
#
|
public
|
withoutTrailers()
Reduce the collection to headers received before the message body
Reduce the collection to headers received before the message body
Implements
|
#
|
public
|
getLines(string $format = '%s: %s', ?string $emptyFormat = null): array
Get header names and values in their original order as a list of field
lines, preserving the original case of each…
Get header names and values in their original order as a list of field
lines, preserving the original case of each header
If $emptyFormat is given, it is used for headers with an empty value.
Implements
|
#
|
public
|
getHeaders(): array
Get an array that maps header names to values, preserving the original
case of the first appearance of each header
Get an array that maps header names to values, preserving the original
case of the first appearance of each header
Implements
|
#
|
public
|
hasHeader(string $name): bool
Check if a header exists
|
#
|
public
|
getHeader(string $name): array
Get the value of a header as a list of values
Get the value of a header as a list of values
Implements
|
#
|
public
|
getHeaderLine(string $name): string
Get the value of a header as a string of comma-delimited values
Get the value of a header as a string of comma-delimited values
Implements
|
#
|
public
|
getHeaderLines(): array
Get an array that maps lowercase header names to comma-separated values
Get an array that maps lowercase header names to comma-separated values
Implements
|
#
|
public
|
getHeaderValues(string $name): array
Get the value of a header as a list of values, splitting any
comma-separated values
Get the value of a header as a list of values, splitting any
comma-separated values
Implements
|
#
|
public
|
getFirstHeaderValue(string $name): string
Get the first value of a header after splitting any comma-separated
values
Get the first value of a header after splitting any comma-separated
values
Implements
|
#
|
public
|
getLastHeaderValue(string $name): string
Get the last value of a header after splitting any comma-separated values
Get the last value of a header after splitting any comma-separated values
Implements
|
#
|
public
|
getOnlyHeaderValue(string $name, bool $orSame = false): string
Get the only value of a header after splitting any comma-separated values
Get the only value of a header after splitting any comma-separated values
Implements
|
#
|
public
|
__toString(): string
|
#
|
public
|
jsonSerialize(): array
|
#
|
protected
|
getItemsArray(
Arrayable<string, string[]|string>|iterable<string, string[]|string> $items,
array<int, array{string, string}>|null &$headers = null,
array<string, int[]>|null &$index = null,
): array<string, string[]>
|
#
|
protected
|
getItems(
Arrayable<string, string[]|string>|iterable<string, string[]|string> $items,
): iterable<string, non-empty-array<string>>
|
#
|
protected
|
compareItems(string[] $a, string[] $b): int
|
#
|
protected
|
generateHeaders(): iterable<string, string>
|
#
|