Web\Url: add matches() function

fixes #6992
This commit is contained in:
Thomas Gelf 2014-09-04 18:46:58 +02:00
parent 201c24107d
commit f91892cb80
1 changed files with 17 additions and 0 deletions

View File

@ -385,6 +385,23 @@ class Url
return $this->params->shift($param, $default);
}
/**
* Whether the given URL matches this URL object
*
* This does an exact match, parameters MUST be in the same order
*
* @param Url|string $url the URL to compare against
*
* @return bool whether the URL matches
*/
public function matches($url)
{
if (! $url instanceof Url) {
$url = Url::fromPath($url);
}
return (string) $url === (string) $this;
}
/**
* Return a copy of this url without the parameter given
*