Negotiation
class Negotiation (View source)
Constants
LOW |
Sort values in the header low to high by q-factors |
HIGH |
Sort values in the header high to low by q-factors |
ALL |
Get all values from a accept header (without q-factor) |
Methods
Create a Negotiation instance
Create a Negotiation instance based in string (eg.: `curl_opt(.
Get all languages by Accept-Language
header sorted by q-factor (defined by $level
)
Get all languages by Accept-Charset
header and sort by q-factor (defined by $level
)
Get all languages by Accept-Encoding
header and sort by q-factor (defined by $level
)
Get all document types by Accept
header and sorted by q-factor (defined by $level
)
Get the first language with with the greatest q-factor,
if it does not exist then return the value of $alternative
Get the first charset with with the greatest q-factor,
if it does not exist then return the value of $alternative
Get the first encoding with with the greatest q-factor,
if it does not exist then return the value of $alternative
Get the first "document type" with the greatest q-factor,
if it does not exist then return the value of $alternative
Parse any header like TE
header or headers with Accepet-
prefix
Parse and sort a custom value with q-factor
Details
at line 35
void
__construct(array $headers = null)
Create a Negotiation instance
at line 64
static void
fromString(string $str)
Create a Negotiation instance based in string (eg.: `curl_opt(.
.., CURL_OPT_HEADER, true)`)
at line 93
array|null
acceptLanguage(int $level = self::HIGH)
Get all languages by Accept-Language
header sorted by q-factor (defined by $level
)
at line 106
array|null
acceptCharset(int $level = self::HIGH)
Get all languages by Accept-Charset
header and sort by q-factor (defined by $level
)
at line 119
array|null
acceptEncoding(string $level = self::HIGH)
Get all languages by Accept-Encoding
header and sort by q-factor (defined by $level
)
at line 132
array|null
accept(int $level = self::HIGH)
Get all document types by Accept
header and sorted by q-factor (defined by $level
)
at line 146
mixed
getLanguage(mixed $alternative = null)
Get the first language with with the greatest q-factor,
if it does not exist then return the value of $alternative
at line 161
mixed
getCharset(mixed $alternative = null)
Get the first charset with with the greatest q-factor,
if it does not exist then return the value of $alternative
at line 176
mixed
getEncoding(mixed $alternative = null)
Get the first encoding with with the greatest q-factor,
if it does not exist then return the value of $alternative
at line 191
mixed
getAccept(mixed $alternative = null)
Get the first "document type" with the greatest q-factor,
if it does not exist then return the value of $alternative
at line 205
array|null
header(string $header, int $level = self::HIGH)
Parse any header like TE
header or headers with Accepet-
prefix
at line 222
static array
qFactor(string $value, int $level = self::HIGH)
Parse and sort a custom value with q-factor