ContentType
in package
implements
HeaderInterface
Tags
Table of Contents
Interfaces
- HeaderInterface
- Interface for HTTP Header classes.
Properties
- $mediaType : string
- $parameters : array<string|int, mixed>
- $value : string
Methods
- __construct() : mixed
- fromString() : static
- Factory method: create an object from a string representation
- getCharset() : null|string
- Get the content-type character set encoding, if any
- getFieldName() : string
- Get the field name
- getFieldValue() : string
- Get the field value
- getMediaType() : string
- Get the media type
- getParameters() : array<string|int, mixed>
- Get any additional content-type parameters currently set
- match() : string|bool
- Determine if the mediatype value in this header matches the provided criteria
- setCharset() : $this
- Set the content-type character set encoding
- setMediaType() : $this
- Set the media type
- setParameters() : $this
- Set additional content-type parameters
- toString() : string
- Create a string representation of the header
- assembleValue() : string
- Assemble the value based on the media type and any available parameters
- getMediaTypeObjectFromString() : stdClass
- Split a mediatype string into an object with the following parts:
- splitMediaTypesFromString() : array<string|int, mixed>
- Split comma-separated media types into an array
- validateFormat() : bool
- Validate the format
- validatePartialWildcard() : bool
- Validate a partial wildcard (i.e., string ending in '*')
- validateSubtype() : bool
- Validate a subtype
Properties
$mediaType
protected
string
$mediaType
$parameters
protected
array<string|int, mixed>
$parameters
= []
$value
protected
string
$value
Methods
__construct()
public
__construct([null|string $value = null ][, null|string $mediaType = null ]) : mixed
Parameters
- $value : null|string = null
- $mediaType : null|string = null
fromString()
Factory method: create an object from a string representation
public
static fromString(string $headerLine) : static
Parameters
- $headerLine : string
Return values
staticgetCharset()
Get the content-type character set encoding, if any
public
getCharset() : null|string
Return values
null|stringgetFieldName()
Get the field name
public
getFieldName() : string
Return values
stringgetFieldValue()
Get the field value
public
getFieldValue() : string
Return values
stringgetMediaType()
Get the media type
public
getMediaType() : string
Return values
stringgetParameters()
Get any additional content-type parameters currently set
public
getParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>match()
Determine if the mediatype value in this header matches the provided criteria
public
match(array<string|int, mixed>|string $matchAgainst) : string|bool
Parameters
- $matchAgainst : array<string|int, mixed>|string
Return values
string|bool —Matched value or false
setCharset()
Set the content-type character set encoding
public
setCharset(string $charset) : $this
Parameters
- $charset : string
Return values
$thissetMediaType()
Set the media type
public
setMediaType(string $mediaType) : $this
Parameters
- $mediaType : string
Return values
$thissetParameters()
Set additional content-type parameters
public
setParameters(array<string|int, mixed> $parameters) : $this
Parameters
- $parameters : array<string|int, mixed>
Return values
$thistoString()
Create a string representation of the header
public
toString() : string
Return values
stringassembleValue()
Assemble the value based on the media type and any available parameters
protected
assembleValue() : string
Return values
stringgetMediaTypeObjectFromString()
Split a mediatype string into an object with the following parts:
protected
getMediaTypeObjectFromString(string $string) : stdClass
- type
- subtype
- format
Parameters
- $string : string
Return values
stdClasssplitMediaTypesFromString()
Split comma-separated media types into an array
protected
splitMediaTypesFromString(string $criteria) : array<string|int, mixed>
Parameters
- $criteria : string
Return values
array<string|int, mixed>validateFormat()
Validate the format
protected
validateFormat(string $right, string $left) : bool
Validate that the right side format matches what the left side defines.
Parameters
- $right : string
- $left : string
Return values
boolvalidatePartialWildcard()
Validate a partial wildcard (i.e., string ending in '*')
protected
validatePartialWildcard(string $right, string $left) : bool
Parameters
- $right : string
- $left : string
Return values
boolvalidateSubtype()
Validate a subtype
protected
validateSubtype(stdClass $right, stdClass $left) : bool
Parameters
- $right : stdClass
- $left : stdClass