class MediaRange implements MediaTypeInterface (View source)

Traits

Methods

string|NULL
getStructuredSyntax(boolean $registeredOnly = false)

No description

setParameters($parameters)

No description

jsonSerialize()

No description

string
serializeToString()

No description

unserializeMediaTypeInterfaceInterface(string $className, string $pattern, string $mediaTypeString, boolean $withParameters)

No description

serialize()

No description

unserialize($serialized)

No description

static 
isMediaTypeMatchMediaRange($mediaType, $mediaRange)

No description

compare(MediaTypeInterface|MediaSubType|string $b)

Compare media range precision

static 
matchStructuredSyntax($a, $b)

No description

__construct(string $type = self::ANY, string $subType = self::ANY)

No description

string
getType()

No description

MediaSubType|string
getSubType()

No description

__toString()

No description

__clone()

No description

true
match(MediaTypeInterface|string $mediaRange)

Check if the MediaType instance match the given MediaRange

static MediaRange
createFromString(string $mediaTypeString, boolean $withParameters = false)

No description

static number
compareMediaRanges(MediaTypeInterface $a, MediaTypeInterface $b)

Compare media range precision

Details

string|NULL getStructuredSyntax(boolean $registeredOnly = false)

Parameters

boolean $registeredOnly Return type only if it is a registered type

Return Value

string|NULL Structured syntax type if any. NULL otherwise

protected setParameters($parameters)

Parameters

$parameters

jsonSerialize()

string serializeToString()

Return Value

string Media type and parameter string representation

static string serializeMediaTypeInterfaceToString(MediaTypeInterface $mediaType)

Parameters

MediaTypeInterface $mediaType

Return Value

string Media Type / Range and parameters

static MediaTypeInterface unserializeMediaTypeInterfaceInterface(string $className, string $pattern, string $mediaTypeString, boolean $withParameters)

Parameters

string $className MediaTypeInterface class
string $pattern Media type string
string $mediaTypeString Media type string
boolean $withParameters Also parse parameters

Return Value

MediaTypeInterface

Exceptions

MediaTypeException

unserialize($serialized)

Parameters

$serialized

static protected isMediaTypeMatchMediaRange($mediaType, $mediaRange)

Parameters

$mediaType
$mediaRange

compare(MediaTypeInterface|MediaSubType|string $b)

Compare media range precision

Parameters

MediaTypeInterface|MediaSubType|string $b Media range to compare

Return Value

if media range are identical, < 0 if $b is more precise,

0 if $b is less precise

Exceptions

NotComparableException

static matchStructuredSyntax($a, $b)

Parameters

$a
$b

__construct(string $type = self::ANY, string $subType = self::ANY)

Parameters

string $type Main type or '*'
string $subType Sub type or '*'

string getType()

Return Value

string

MediaSubType|string getSubType()

Return Value

MediaSubType|string

__toString()

__clone()

true match(MediaTypeInterface|string $mediaRange)

Check if the MediaType instance match the given MediaRange

Parameters

MediaTypeInterface|string $mediaRange

Return Value

true if $mediaRange is identical or less restrictive than $this

See also

MediaTypeInterface::match

static MediaRange createFromString(string $mediaTypeString, boolean $withParameters = false)

Parameters

string $mediaTypeString Media type string
boolean $withParameters Also parse parameters

Return Value

MediaRange

Exceptions

MediaTypeException

static number compareMediaRanges(MediaTypeInterface $a, MediaTypeInterface $b)

Compare media range precision

Parameters

MediaTypeInterface $a
MediaTypeInterface $b

Return Value

number -1 if $a < $b, 1 if $a > $b, 0 if equal or not comparable