Media\Type
Type Class
Following iana's Media Type List www.iana.org/assignments/media-types/media-types.xhtml
Emvicy provides single classes for each of the > 2000 Types. Each class comes with:
- Media Type Description in its class name (e.g.
Type_Application_json
) - constant
DESCRIPTION
, containing the (string) Media Type Description - static method
header()
, which sends a header withContent-Type:
DESCRIPTION
All classes are divided into the following types
application
audio
font
haptics
image
message
model
multipart
text
video
So in fact type application classes are named Type_Application_*
(e.g. Type_Application_json
),
while type image classes are named Type_Image_*
(e.g. Type_Image_gif
)
Example: \MVC\Media\Type_Application_json
<?php
/**
* Type_Application_json.php
* @package Emvicy
* @copyright ueffing.net
* @author Guido K.B.W. Üffing <emvicy@ueffing.net>
* @license GNU GENERAL PUBLIC LICENSE Version 3. See application/doc/COPYING
*/
namespace MVC\Media;
use MVC\MVCTrait\TraitMediaType;
class Type_Application_json
{
use TraitMediaType;
/**
* @reference [RFC8259]
*/
const DESCRIPTION = 'application/json';
}
sends a header with Content-Type:
(string) DESCRIPTION
\MVC\Media\Type_Application_json::header();
contains (string) application/json
$sMediaTypeDescription = \MVC\Media\Type_Application_json::DESCRIPTION;
Media Type List
for a full List of iana Media Types see www.iana.org/assignments/media-types/media-types.xhtml