/** * @ticket https://github.com/guzzle/guzzle/issues/90 */ public function testAllowsNestedArrayExpansion() { $template = new UriTemplate(); $result = $template->expand('http://example.com{+path}{/segments}{?query,data*,foo*}', array('path' => '/foo/bar', 'segments' => array('one', 'two'), 'query' => 'test', 'data' => array('more' => array('fun', 'ice cream')), 'foo' => array('baz' => array('bar' => 'fizz', 'test' => 'buzz'), 'bam' => 'boo'))); $this->assertEquals('http://example.com/foo/bar/one,two?query=test&more%5B0%5D=fun&more%5B1%5D=ice%20cream&baz%5Bbar%5D=fizz&baz%5Btest%5D=buzz&bam=boo', $result); }
/** * Expands a URI template * * @param string $template URI template * @param array $variables Template variables * * @return string */ public static function uriTemplate($template, array $variables) { if (function_exists('\\uri_template')) { return \uri_template($template, $variables); } static $uriTemplate; if (!$uriTemplate) { $uriTemplate = new UriTemplate(); } return $uriTemplate->expand($template, $variables); }