mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-25 15:00:58 +01:00
23786784ef
Summary: Adds the Balanced PHP API to externals/. Ref T2787. Test Plan: Used in next diff. Reviewers: btrahan, chad Reviewed By: chad CC: aran, aurelijus Maniphest Tasks: T2787 Differential Revision: https://secure.phabricator.com/D5764
46 lines
No EOL
1.1 KiB
PHP
46 lines
No EOL
1.1 KiB
PHP
<?php
|
|
|
|
namespace Httpful;
|
|
|
|
class Httpful {
|
|
const VERSION = '0.1.7';
|
|
|
|
private static $mimeRegistrar = array();
|
|
private static $default = null;
|
|
|
|
/**
|
|
* @param string $mime_type
|
|
* @param MimeHandlerAdapter $handler
|
|
*/
|
|
public static function register($mimeType, \Httpful\Handlers\MimeHandlerAdapter $handler)
|
|
{
|
|
self::$mimeRegistrar[$mimeType] = $handler;
|
|
}
|
|
|
|
/**
|
|
* @param string $mime_type defaults to MimeHandlerAdapter
|
|
* @return MimeHandlerAdapter
|
|
*/
|
|
public static function get($mimeType = null)
|
|
{
|
|
if (isset(self::$mimeRegistrar[$mimeType])) {
|
|
return self::$mimeRegistrar[$mimeType];
|
|
}
|
|
|
|
if (empty(self::$default)) {
|
|
self::$default = new \Httpful\Handlers\MimeHandlerAdapter();
|
|
}
|
|
|
|
return self::$default;
|
|
}
|
|
|
|
/**
|
|
* Does this particular Mime Type have a parser registered
|
|
* for it?
|
|
* @return bool
|
|
*/
|
|
public static function hasParserRegistered($mimeType)
|
|
{
|
|
return isset(self::$mimeRegistrar[$mimeType]);
|
|
}
|
|
} |