| Total Complexity | 5 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class Httpful { |
||
| 6 | const VERSION = '0.2.18'; |
||
| 7 | |||
| 8 | private static $mimeRegistrar = array(); |
||
| 9 | private static $default = null; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @param string $mime_type |
||
| 13 | * @param MimeHandlerAdapter $handler |
||
| 14 | */ |
||
| 15 | public static function register($mimeType, \Httpful\Handlers\MimeHandlerAdapter $handler) |
||
| 16 | { |
||
| 17 | self::$mimeRegistrar[$mimeType] = $handler; |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param string $mime_type defaults to MimeHandlerAdapter |
||
| 22 | * @return MimeHandlerAdapter |
||
| 23 | */ |
||
| 24 | public static function get($mimeType = null) |
||
| 25 | { |
||
| 26 | if (isset(self::$mimeRegistrar[$mimeType])) { |
||
| 27 | return self::$mimeRegistrar[$mimeType]; |
||
| 28 | } |
||
| 29 | |||
| 30 | if (empty(self::$default)) { |
||
| 31 | self::$default = new \Httpful\Handlers\MimeHandlerAdapter(); |
||
| 32 | } |
||
| 33 | |||
| 34 | return self::$default; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Does this particular Mime Type have a parser registered |
||
| 39 | * for it? |
||
| 40 | * @return bool |
||
| 41 | */ |
||
| 42 | public static function hasParserRegistered($mimeType) |
||
| 43 | { |
||
| 44 | return isset(self::$mimeRegistrar[$mimeType]); |
||
| 45 | } |
||
| 47 |