AcceptHeader
in package
Represents an Accept-* header.
An accept header is compound with a list of items, sorted by descending quality.
Tags
Table of Contents
- $items : array<string|int, AcceptHeaderItem>
- $sorted : bool
- __construct() : mixed
- __toString() : string
- Returns header value's string representation.
- add() : $this
- Adds an item.
- all() : array<string|int, AcceptHeaderItem>
- Returns all items.
- filter() : self
- Filters items on their value using given regex.
- first() : AcceptHeaderItem|null
- Returns first item.
- fromString() : self
- Builds an AcceptHeader instance from a string.
- get() : AcceptHeaderItem|null
- Returns given value's item, if exists.
- has() : bool
- Tests if header has given value.
- sort() : void
- Sorts items by descending quality.
Properties
$items
private
array<string|int, AcceptHeaderItem>
$items
= []
$sorted
private
bool
$sorted
= true
Methods
__construct()
public
__construct(array<string|int, AcceptHeaderItem> $items) : mixed
Parameters
- $items : array<string|int, AcceptHeaderItem>
Return values
mixed —__toString()
Returns header value's string representation.
public
__toString() : string
Return values
string —add()
Adds an item.
public
add(AcceptHeaderItem $item) : $this
Parameters
- $item : AcceptHeaderItem
Return values
$this —all()
Returns all items.
public
all() : array<string|int, AcceptHeaderItem>
Return values
array<string|int, AcceptHeaderItem> —filter()
Filters items on their value using given regex.
public
filter(string $pattern) : self
Parameters
- $pattern : string
Return values
self —first()
Returns first item.
public
first() : AcceptHeaderItem|null
Return values
AcceptHeaderItem|null —fromString()
Builds an AcceptHeader instance from a string.
public
static fromString(string|null $headerValue) : self
Parameters
- $headerValue : string|null
Return values
self —get()
Returns given value's item, if exists.
public
get(string $value) : AcceptHeaderItem|null
Parameters
- $value : string
Return values
AcceptHeaderItem|null —has()
Tests if header has given value.
public
has(string $value) : bool
Parameters
- $value : string
Return values
bool —sort()
Sorts items by descending quality.
private
sort() : void