MimeMap

TypeInterface

Interface for Type objects.

Table of Contents

Methods

__construct()  : mixed
Constructor.
addParameter()  : void
Add a parameter to this type
buildTypesList()  : array<int, int|string>
Builds a list of MIME types existing in the map.
getAliases()  : array<int, string>
Returns all the aliases related to the MIME type(s).
getDefaultExtension()  : string
Returns the MIME type's preferred file extension.
getDescription()  : string
Returns a description for the MIME type, if existing in the map.
getExtensions()  : array<int, string>
Returns all the file extensions related to the MIME type(s).
getMedia()  : string
Gets a MIME type's media.
getMediaComment()  : string
Gets the MIME type's media comment.
getParameter()  : TypeParameter
Get a MIME type's parameter.
getParameters()  : array<string|int, TypeParameter>
Get the MIME type's parameters.
getSubType()  : string
Gets a MIME type's subtype.
getSubTypeComment()  : string
Gets the MIME type's subtype comment.
hasDescription()  : bool
Checks if a description for the MIME type exists.
hasMediaComment()  : bool
Checks if the MIME type has media comment.
hasParameter()  : bool
Checks if the MIME type has a parameter.
hasParameters()  : bool
Checks if the MIME type has any parameter.
hasSubTypeComment()  : bool
Checks if the MIME type has subtype comment.
isAlias()  : bool
Is this an alias?
isExperimental()  : bool
Is this type experimental?
isVendor()  : bool
Is this a vendor MIME type?
isWildcard()  : bool
Is this a wildcard type?
removeParameter()  : void
Remove a parameter from this type.
setMedia()  : TypeInterface
Sets a MIME type's media.
setMediaComment()  : TypeInterface
Sets the MIME type's media comment.
setSubType()  : TypeInterface
Sets a MIME type's subtype.
setSubTypeComment()  : TypeInterface
Sets the MIME type's subtype comment.
toString()  : string
Create a textual MIME type from object values.
wildcardMatch()  : bool
Perform a wildcard match on a MIME type

Methods

__construct()

Constructor.

public __construct(string $typeString[, MimeMapInterface>|null $mapClass = null ]) : mixed
APIYes

The type string will be parsed and the appropriate class vars set.

Parameters
$typeString : string

MIME type string to be parsed.

$mapClass : MimeMapInterface>|null = null

(Optional) The FQCN of the map class to use.

addParameter()

Add a parameter to this type

public addParameter(string $name, string $value[, string|null $comment = null ]) : void
APIYes
Parameters
$name : string
$value : string
$comment : string|null = null

buildTypesList()

Builds a list of MIME types existing in the map.

public buildTypesList() : array<int, int|string>
APIYes

If the current type is a wildcard, than all the types matching the wildcard will be returned.

Tags
throws
MappingException

if no mapping found.

Return values
array<int, int|string>

getAliases()

Returns all the aliases related to the MIME type(s).

public getAliases() : array<int, string>
APIYes

If the current type is a wildcard, than all aliases of all the types matching the wildcard will be returned.

Tags
throws
MappingException

on error.

Return values
array<int, string>

getDefaultExtension()

Returns the MIME type's preferred file extension.

public getDefaultExtension() : string
APIYes
Tags
throws
MappingException

if no mapping found.

Return values
string

getDescription()

Returns a description for the MIME type, if existing in the map.

public getDescription([bool $includeAcronym = false ]) : string
APIYes
Parameters
$includeAcronym : bool = false

(Optional) if true and an acronym description exists for the type, the returned description will contain the acronym and its description, appended with a comma. Defaults to false.

Tags
throws
MappingException

if no description found.

Return values
string

getExtensions()

Returns all the file extensions related to the MIME type(s).

public getExtensions() : array<int, string>
APIYes

If the current type is a wildcard, than all extensions of all the types matching the wildcard will be returned.

Tags
throws
MappingException

if no mapping found.

Return values
array<int, string>

getMedia()

Gets a MIME type's media.

public getMedia() : string
APIYes

Note: 'media' refers to the portion before the first slash.

Return values
string

getSubType()

Gets a MIME type's subtype.

public getSubType() : string
APIYes
Return values
string

getSubTypeComment()

Gets the MIME type's subtype comment.

public getSubTypeComment() : string
APIYes
Tags
throws
UndefinedException
Return values
string

hasDescription()

Checks if a description for the MIME type exists.

public hasDescription() : bool
APIYes
Return values
bool

hasMediaComment()

Checks if the MIME type has media comment.

public hasMediaComment() : bool
APIYes
Return values
bool

hasParameter()

Checks if the MIME type has a parameter.

public hasParameter(string $name) : bool
APIYes
Parameters
$name : string
Tags
throws
UndefinedException
Return values
bool

hasParameters()

Checks if the MIME type has any parameter.

public hasParameters() : bool
APIYes
Return values
bool

hasSubTypeComment()

Checks if the MIME type has subtype comment.

public hasSubTypeComment() : bool
APIYes
Return values
bool

isAlias()

Is this an alias?

public isAlias() : bool
APIYes
Return values
bool

isExperimental()

Is this type experimental?

public isExperimental() : bool
APIYes

Note: Experimental types are denoted by a leading 'x-' in the media or subtype, e.g. text/x-vcard or x-world/x-vrml.

Return values
bool

isVendor()

Is this a vendor MIME type?

public isVendor() : bool
APIYes

Note: Vendor types are denoted with a leading 'vnd. in the subtype.

Return values
bool

isWildcard()

Is this a wildcard type?

public isWildcard() : bool
APIYes
Return values
bool

removeParameter()

Remove a parameter from this type.

public removeParameter(string $name) : void
APIYes
Parameters
$name : string

setMediaComment()

Sets the MIME type's media comment.

public setMediaComment([string $comment = null ]) : TypeInterface
APIYes
Parameters
$comment : string = null

(optional) a comment; when missing any existing comment is removed.

Return values
TypeInterface

setSubTypeComment()

Sets the MIME type's subtype comment.

public setSubTypeComment([string|null $comment = null ]) : TypeInterface
APIYes
Parameters
$comment : string|null = null

(optional) a comment; when missing any existing comment is removed.

Return values
TypeInterface

toString()

Create a textual MIME type from object values.

public toString([int $format = Type::FULL_TEXT ]) : string
APIYes

This function performs the opposite function of parse().

Parameters
$format : int = Type::FULL_TEXT

The format of the output string.

Return values
string

wildcardMatch()

Perform a wildcard match on a MIME type

public wildcardMatch(string $wildcard) : bool
APIYes

Example: $type = new Type('image/png'); $type->wildcardMatch('image/*');

Parameters
$wildcard : string

Wildcard to check against.

Return values
bool

True if there was a match, false otherwise.


        
On this page

Search results