34 private $methods = array();
39 private $ips = array();
44 private $attributes = array();
49 private $schemes = array();
59 public function __construct($path =
null, $host =
null, $methods =
null, $ips =
null, array $attributes = array(), $schemes =
null)
67 foreach ($attributes as $k => $v) {
79 $this->schemes =
null !== $scheme ? array_map(
'strtolower', (array) $scheme) : array();
89 $this->host = $regexp;
99 $this->path = $regexp;
119 $this->ips =
null !== $ips ? (array) $ips : array();
129 $this->methods =
null !== $method ? array_map(
'strtoupper', (array) $method) : array();
140 $this->attributes[$key] = $regexp;
148 if ($this->schemes && !in_array($request->getScheme(), $this->schemes,
true)) {
152 if ($this->methods && !in_array($request->getMethod(), $this->methods,
true)) {
156 foreach ($this->attributes as $key => $pattern) {
157 if (!preg_match(
'{'.$pattern.
'}', $request->attributes->get($key))) {
162 if (
null !== $this->path && !preg_match(
'{'.$this->path.
'}', rawurldecode($request->getPathInfo()))) {
166 if (
null !== $this->host && !preg_match(
'{'.$this->host.
'}i', $request->getHost())) {
176 return count($this->ips) === 0;