Open Journal Systems  3.3.0
ParserRegistry.php
1 <?php
2 
3 namespace Guzzle\Parser;
4 
9 {
11  protected static $instance;
12 
14  protected $instances = array();
15 
17  protected $mapping = array(
18  'message' => 'Guzzle\\Parser\\Message\\MessageParser',
19  'cookie' => 'Guzzle\\Parser\\Cookie\\CookieParser',
20  'url' => 'Guzzle\\Parser\\Url\\UrlParser',
21  'uri_template' => 'Guzzle\\Parser\\UriTemplate\\UriTemplate',
22  );
23 
28  public static function getInstance()
29  {
30  if (!self::$instance) {
31  self::$instance = new static;
32  }
33 
35  }
36 
37  public function __construct()
38  {
39  // Use the PECL URI template parser if available
40  if (extension_loaded('uri_template')) {
41  $this->mapping['uri_template'] = 'Guzzle\\Parser\\UriTemplate\\PeclUriTemplate';
42  }
43  }
44 
52  public function getParser($name)
53  {
54  if (!isset($this->instances[$name])) {
55  if (!isset($this->mapping[$name])) {
56  return null;
57  }
58  $class = $this->mapping[$name];
59  $this->instances[$name] = new $class();
60  }
61 
62  return $this->instances[$name];
63  }
64 
71  public function registerParser($name, $parser)
72  {
73  $this->instances[$name] = $parser;
74  }
75 }
Guzzle\Parser\ParserRegistry
Definition: ParserRegistry.php:8
Guzzle\Parser\ParserRegistry\registerParser
registerParser($name, $parser)
Definition: ParserRegistry.php:77
Guzzle\Parser\ParserRegistry\getInstance
static getInstance()
Definition: ParserRegistry.php:34
Guzzle\Parser\ParserRegistry\$instances
$instances
Definition: ParserRegistry.php:17
Guzzle\Parser\ParserRegistry\getParser
getParser($name)
Definition: ParserRegistry.php:58
Guzzle\Parser\ParserRegistry\__construct
__construct()
Definition: ParserRegistry.php:43
Guzzle\Parser\ParserRegistry\$instance
static $instance
Definition: ParserRegistry.php:12
Guzzle\Parser\ParserRegistry\$mapping
$mapping
Definition: ParserRegistry.php:23
Guzzle\Parser