Download the PHP package keven/media-type without Composer
On this page you can find all versions of the php package keven/media-type. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package media-type
keven/media-type
Simple RFC 6838 media type manipulation and validation library.
This module will parse a given media type into its component parts, like type, subtype, and suffix. A formatter is also provided to put them back together and the two can be combined to normalize media types into a canonical form.
Installation
API
Parsing
Parse a media type string. This will return an object with the following
properties (examples are shown for the string 'image/vnd.svg+xml; charset=utf-8'
):
type
: The type of the media type (always lower case). Example:'image'
subtype
: The subtype of the media type (always lower case). Example:'svg'
tree
: The tree (~vendor) of the media type (always lower case). Example:'vnd'
suffix
: The suffix of the media type (always lower case). Example:'xml'
-
parameters
: The parameters added to the end of the media type. Exemple:['charset' => 'utf-8']
- If the given type string is invalid, then a
InvalidMediaTypeException
is thrown.
Formatting
Format an object into a media type string. This will return a string of the mime type for the given object.
Validation
Validate a media type string. This will return true
if the string is a well-
formatted media type, or false
otherwise.
You can also assert if the type is valid by passing a second parameter.
License
MIT