public function parse($url)
{
foreach ($this->map as $pattern) {
$pattern = $this->compile($pattern);
if (preg_match($pattern, $url, $match)) {
// remove numeric keys
foreach ($match as $key => $value) {
if (is_numeric($key)) {
unset($match[$key]);
}
}
return $match;
}
}
throw new Exceptions\InvalidArgumentException("URL '{$url}' did not match any route.");
}
/** * Test parsing when pattern does not match the end of the URL * * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException * @expectedExceptionMessage URL '/foo/23/bar' did not match any route. */ public function testPatternDoesNotMatchTrailing() { $urlHandler = new Common\RequestParser\Pattern(array('pattern' => '/foo/{foo}')); $urlHandler->parse('/foo/23/bar'); }