QualityValue
in package
HTTP quality value class
Generic RFC 7231 Section 5.3.1 "value;q=N" list parser - has no knowledge of media types, so it applies equally to Accept, Accept-Language, Accept-Encoding and Accept-Charset.
Tags
Table of Contents
Properties
- $quality : float
- The quality weight, 0.0 - 1.0
- $value : string
- The raw value (e.g. 'text/html', 'en-US')
Methods
- __construct() : mixed
- Constructor
- getQuality() : float
- Get the quality weight
- getValue() : string
- Get the raw value
- parseList() : array<string|int, QualityValue>
- Parse a raw header value into a list of QualityValue entries, sorted by quality descending (stable sort - original order preserved among entries of equal quality).
Properties
$quality
The quality weight, 0.0 - 1.0
protected
float
$quality
$value
The raw value (e.g. 'text/html', 'en-US')
protected
string
$value
Methods
__construct()
Constructor
public
__construct(string $value[, float $quality = 1.0 ]) : mixed
Parameters
- $value : string
- $quality : float = 1.0
getQuality()
Get the quality weight
public
getQuality() : float
Return values
floatgetValue()
Get the raw value
public
getValue() : string
Return values
stringparseList()
Parse a raw header value into a list of QualityValue entries, sorted by quality descending (stable sort - original order preserved among entries of equal quality).
public
static parseList(string $header) : array<string|int, QualityValue>
A missing or malformed 'q' parameter defaults to 1.0 rather than being dropped or throwing - this is client-controlled input, and a malformed weight shouldn't fail the request, only fail to deprioritize correctly.
Parameters
- $header : string