Negotiation
class Negotiation (View source)
Constants
| LOW |
|
| HIGH |
|
| ALL |
|
Methods
Create a Negotiation instance from request headers or from a Array
Create a Negotiation instance based in string
Parse any header with q-factor value
Get all document types from Accept header and sorted by q-factor (defined by $sort)
Get all encodings from Accept-Encoding header and sort by q-factor (defined by $sort)
Get all languages from Accept-Language header sorted by q-factor (defined by $sort)
Get the highest priority option from the header
Get the document type (from Accept header) with the highest
priority based on the q value. If it does not exist then return
the value of $alternative.
Get the encoding (from Accept-Encoding header) with the highest
priority based on the q value. If it does not exist then return
the value of $alternative.
Get the encoding (from Accept-Language header) with the highest
priority based on the q value. If it does not exist then return
the value of $alternative.
Parse and sort a custom value with q-factor
Details
__construct(array $headers = array())
Create a Negotiation instance from request headers or from a Array
static Negotiation
fromString(string $str)
Create a Negotiation instance based in string
array|null
entries(string $header, int $sort = self::HIGH)
Parse any header with q-factor value
array|null
contentTypes(int $sort = self::HIGH)
Get all document types from Accept header and sorted by q-factor (defined by $sort)
array|null
encodings(int $sort = self::HIGH)
Get all encodings from Accept-Encoding header and sort by q-factor (defined by $sort)
array|null
languages(int $sort = self::HIGH)
Get all languages from Accept-Language header sorted by q-factor (defined by $sort)
mixed
top(mixed $header, mixed $alternative)
Get the highest priority option from the header
mixed
topContentType(mixed $alternative = null)
Get the document type (from Accept header) with the highest
priority based on the q value. If it does not exist then return
the value of $alternative.
mixed
topEncoding(mixed $alternative = null)
Get the encoding (from Accept-Encoding header) with the highest
priority based on the q value. If it does not exist then return
the value of $alternative.
mixed
topLanguage(mixed $alternative = null)
Get the encoding (from Accept-Language header) with the highest
priority based on the q value. If it does not exist then return
the value of $alternative.
static array
qFactor(string $value, Negotiation::LOW|Negotiation::HIGH|Negotiation::ALL $sort = self::HIGH)
Parse and sort a custom value with q-factor