class RequestMediaTypeParser (View source)

Constants

OWS_CHARS

Optional white space characters.

PARAMETER_SEPARATOR_CHAR

Parameter-separator character.

LIST_SEPARATOR_CHAR

List-separator character.

RX_TOKEN

Regular expression chunk: token.

RX_QUOTED_STRING

Regular expression chunk: quoted string.

RX_TYPE

Regular expression chunk: type.

RX_SUBTYPE

Regular expression chunk: sub-type.

Properties

protected Request $request
private array|null $requestAcceptMap

Methods

__construct(Request $request)

Initialize the instance.

bool
isMediaTypeSupported(string|string[] $mediaType, float|null $minWeight = null)

Check if the client signaled that it supports a media type.

array
getMediaTypeData(string|string[] $mediaType)

Get the data associated to a media type.

array
getRequestAcceptMap()

Get the data extracted from the 'Accept' header.

getRequestAccept()

Get the 'Accept' header of the request.

array
parseRequestAccept(string $accept)

No description

array
sortRequestAcceptMap(array $requestAcceptMap)

No description

string
string
string[]
normalizeMediaType(string|string[] $mediaType)

No description

string[]
getMediaTypeAlternatives(string $type, string $subType)

No description

Details

__construct(Request $request)

Initialize the instance.

Parameters

Request $request

bool isMediaTypeSupported(string|string[] $mediaType, float|null $minWeight = null)

Check if the client signaled that it supports a media type.

Parameters

string|string[] $mediaType

the media type to be checked (a string like 'text/html', or an array like ['text','html'])

float|null $minWeight

the minimum weight of the found media type (from 0 to 1); if NULL we won't check it

Return Value

bool

array getMediaTypeData(string|string[] $mediaType)

Get the data associated to a media type.

Parameters

string|string[] $mediaType

the media type to be checked (a string like 'text/html', or an array like ['text','html'])

Return Value

array

keys are the media type; values are the associated data, sorted by the preferred type (the 'q' parameter)

array getRequestAcceptMap()

Get the data extracted from the 'Accept' header.

Return Value

array

keys are the media type; values are the associated data, sorted by the preferred type (the 'q' parameter)

Examples

<code>['image/png' => ['q' => 1.0], 'image/*' => ['q' => 0.8]]

protected getRequestAccept()

Get the 'Accept' header of the request.

protected array parseRequestAccept(string $accept)

No description

Parameters

string $accept

Return Value

array

protected array sortRequestAcceptMap(array $requestAcceptMap)

No description

Parameters

array $requestAcceptMap

Return Value

array

protected string getTypeSubtypeRegularExpression()

No description

Return Value

string

protected string getParameterAndValueRegularExpression()

No description

Return Value

string

protected string[] normalizeMediaType(string|string[] $mediaType)

No description

Parameters

string|string[] $mediaType

Return Value

string[]

protected string[] getMediaTypeAlternatives(string $type, string $subType)

No description

Parameters

string $type
string $subType

Return Value

string[]