1: <?php
2:
3: namespace Guzzle\Parser\UriTemplate;
4:
5: use Guzzle\Common\Exception\RuntimeException;
6:
7: /**
8: * Expands URI templates using the uri_template pecl extension (pecl install uri_template-beta)
9: *
10: * @link http://pecl.php.net/package/uri_template
11: * @link https://github.com/ioseb/uri-template
12: */
13: class PeclUriTemplate implements UriTemplateInterface
14: {
15: /**
16: * Validates that the uri_template extension is installed
17: * @codeCoverageIgnore
18: */
19: public function __construct()
20: {
21: if (!extension_loaded('uri_template')) {
22: throw new RuntimeException('uri_template PECL extension must be installed to use PeclUriTemplate');
23: }
24: }
25:
26: /**
27: * {@inheritdoc}
28: */
29: public function expand($template, array $variables)
30: {
31: return uri_template($template, $variables);
32: }
33: }
34: