@api
Overrides RequestMatcherInterface::matches
public function matches(Request $request) {
if ($this->methods && !in_array($request
->getMethod(), $this->methods)) {
return false;
}
foreach ($this->attributes as $key => $pattern) {
if (!preg_match('{' . $pattern . '}', $request->attributes
->get($key))) {
return false;
}
}
if (null !== $this->path && !preg_match('{' . $this->path . '}', rawurldecode($request
->getPathInfo()))) {
return false;
}
if (null !== $this->host && !preg_match('{' . $this->host . '}i', $request
->getHost())) {
return false;
}
if (IpUtils::checkIp($request
->getClientIp(), $this->ips)) {
return true;
}
// Note to future implementors: add additional checks above the
// foreach above or else your check might not be run!
return count($this->ips) === 0;
}