/**
* @return mixed|null
*/
public function getRoute()
{
$this->_routeMap->sortRoutes();
foreach ($this->_routeMap as $route) {
if ($this->_request->getMethod() !== $route->getRequestMethod()) {
continue;
}
$route->replaceTokens();
if (preg_match(sprintf("#^%s\$#i", $route->getPattern()), $this->_request->getUri()->getPath(), $matches)) {
$this->_request = $this->_request->withAttribute('match', $route->getPattern());
foreach ($matches as $key => $value) {
if (!is_int($key)) {
$this->_request = $this->_request->withAttribute($key, $value);
}
}
return $route;
}
}
return null;
}