From d3f6c031687d532c1bb32e3eb362da4a948d4750 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sun, 19 Apr 2020 12:07:41 -0400 Subject: [PATCH] Document MIME type group feature --- CHANGELOG | 6 ++++++ README.md | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 6e216e3..7d2fdd6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +Version 0.2.0 (2020-04-19) +========================== + +New features: +- Expose a MIME type's groups via is* (e.g. isAudioVideo) boolean properties + Version 0.1.1 (2020-04-17) ========================== diff --git a/README.md b/README.md index b545d9b..ba6fa0c 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,15 @@ $typeString = 'TeXt/HTML; CHARset="UTF\-8"; charset=iso-8859-1; unset='; $mimeType = \MensBeam\Mime\MimeType::parse($typeString); echo (string) $mimeType; // prints "text/html;charset=UTF-8" ``` + +### MIME type groups + +The MIME Sniffing specification defines a series of [MIME type groups](https://mimesniff.spec.whatwg.org/#mime-type-groups); these are exposed via the boolean properties `isArchive`, `isAudioVideo`, `isFont`, `isHtml`, `isImage`, `isJavascript`, `isJson`, `isScriptable`, `isXml`, and `isZipBased`. For example: + +```php +$mimeType = \MensBeam\Mime\MimeType::parse("image/svg+xml"); +var_export($mimeType->isImage); // prints "true" +var_export($mimeType->isXml); // prints "true" +var_export($mimeType->isScriptable); // prints "true" +var_export($mimeType->isArchive); // prints "false" +```