/**
* Tries to match the given url against current RouteCollection.
*
* @param string|UrlObject $url Url to match.
*
* @return MatchedRoute|bool MatchedRoute instance is returned if url was matched. Otherwise false is returned.
*/
public function match($url)
{
if ($this->isString($url)) {
$url = $this->url($url);
} else {
$url = StdObjectWrapper::isUrlObject($url) ? $url : $this->url('');
}
// get it from cache
if (($result = $this->loadFromCache('match.' . $url->val())) !== false) {
return $this->unserialize($result);
}
// try to match the url
$result = $this->urlMatcher->match($url);
// cache it
$cacheResult = $this->isArray($result) ? $this->serialize($result) : $result;
$this->saveToCache('match.' . $url->val(), $cacheResult);
return $result;
}