neoncitylights / php-media-type

PHP library for supporting IANA media types

Home Page:https://neoncitylights.github.io/php-media-type/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MediaType

Packagist Version GitHub Build Status codecov

MediaType is a PHP library for dealing with IANA media types as entities.

This library is compliant to RFC 20451, and takes references from RFC 20462, RFC 68383, and the WHATWG Mime Sniffing Standard4.

Install

composer require neoncitylights/media-type

Usage

<?php

use Neoncitylights\MediaType\MediaType;

$mediaType = MediaType::newFromString( 'text/plain;charset=UTF-8' );

print( $mediaType->getType() );
// 'text'

print( $mediaType->getSubType() );
// 'plain'

print( $mediaType->getEssence() );
// 'text/plain'

print( $mediaType->getParameterValue( 'charset' ) );
// 'UTF-8'

License

MediaType is licensed under the MIT license.

Footnotes

  1. Freed, N., Innosoft, & Borenstein, N. (1996, November). Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies. Retrieved October 29, 2020, from https://tools.ietf.org/html/rfc2045

  2. Freed, N., I., & Borenstein, N. (2016, November). Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types. Retrieved October 29, 2020, from https://tools.ietf.org/html/rfc2046

  3. Freed, N., O., Klensin, J., Hansen, T., & A. (2013, January). Media Type Specifications and Registration Procedures. Retrieved October 29, 2020, from https://tools.ietf.org/html/rfc6838

  4. Hemsley, G. P., Barth, A., & Hickson, I. (2020, September 30). MIME Sniffing Standard. Retrieved October 29, 2020, from https://mimesniff.spec.whatwg.org/

About

PHP library for supporting IANA media types

https://neoncitylights.github.io/php-media-type/

License:MIT License


Languages

Language:PHP 100.0%