[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace Httpful; 4 5 /** 6 * Class to organize the Mime stuff a bit more 7 * @author Nate Good <[email protected]> 8 */ 9 class Mime 10 { 11 const JSON = 'application/json'; 12 const XML = 'application/xml'; 13 const XHTML = 'application/html+xml'; 14 const FORM = 'application/x-www-form-urlencoded'; 15 const PLAIN = 'text/plain'; 16 const JS = 'text/javascript'; 17 const HTML = 'text/html'; 18 const YAML = 'application/x-yaml'; 19 const CSV = 'text/csv'; 20 21 /** 22 * Map short name for a mime type 23 * to a full proper mime type 24 */ 25 public static $mimes = array( 26 'json' => self::JSON, 27 'xml' => self::XML, 28 'form' => self::FORM, 29 'plain' => self::PLAIN, 30 'text' => self::PLAIN, 31 'html' => self::HTML, 32 'xhtml' => self::XHTML, 33 'js' => self::JS, 34 'javascript'=> self::JS, 35 'yaml' => self::YAML, 36 'csv' => self::CSV, 37 ); 38 39 /** 40 * Get the full Mime Type name from a "short name". 41 * Returns the short if no mapping was found. 42 * @return string full mime type (e.g. application/json) 43 * @param string common name for mime type (e.g. json) 44 */ 45 public static function getFullMime($short_name) 46 { 47 return array_key_exists($short_name, self::$mimes) ? self::$mimes[$short_name] : $short_name; 48 } 49 50 /** 51 * @return bool 52 * @param string $short_name 53 */ 54 public static function supportsMimeType($short_name) 55 { 56 return array_key_exists($short_name, self::$mimes); 57 } 58 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |