39 private $methods = [];
49 private $attributes = [];
54 private $schemes = [];
61 public function __construct(
string $path =
null,
string $host =
null, $methods =
null, $ips =
null, array $attributes = [], $schemes =
null,
int $port =
null)
70 foreach ($attributes as $k => $v) {
82 $this->schemes =
null !== $scheme ? array_map(
'strtolower', (array) $scheme) : [];
92 $this->host = $regexp;
112 $this->path = $regexp;
132 $this->ips =
null !== $ips ? (array) $ips : [];
142 $this->methods =
null !== $method ? array_map(
'strtoupper', (array) $method) : [];
153 $this->attributes[$key] = $regexp;
161 if ($this->schemes && !\in_array($request->
getScheme(), $this->schemes,
true)) {
165 if ($this->methods && !\in_array($request->
getMethod(), $this->methods,
true)) {
169 foreach ($this->attributes as $key => $pattern) {
170 if (!preg_match(
'{'.$pattern.
'}', $request->attributes->
get($key))) {
175 if (
null !== $this->path && !preg_match(
'{'.$this->path.
'}', rawurldecode($request->
getPathInfo()))) {
179 if (
null !== $this->host && !preg_match(
'{'.$this->host.
'}i', $request->
getHost())) {
183 if (
null !== $this->port && 0 < $this->port && $request->
getPort() !== $this->port) {
193 return 0 === \count($this->ips);