98 if ($this->matchUri !==
null)
103 $this->matchUri =
"#^{$this->getUri()}$#";
104 $this->parameters = [];
107 preg_match_all(
'/{([a-z0-9_]+)}/i', $this->
getUri(), $matches);
108 $parameterNames = $matches[1];
110 foreach ($parameterNames as $parameterName)
117 if ($this->options->hasWhere($parameterName))
120 $pattern = $this->options->getWhere($parameterName);
122 elseif ($this->options->hasDefault($parameterName))
129 if ($pattern ===
null)
135 $this->parameters[$parameterName] = $pattern;
138 $this->matchUri = str_replace(
139 "{{$parameterName}}",
140 "(?<{$parameterName}>{$pattern})",
164 if (strpos($this->
getUri(),
'{') !==
false)
170 $result = preg_match($this->matchUri, $uriPath, $matches);
175 $requestParameters = [];
176 $parametersList = array_keys($this->parameters);
178 foreach ($parametersList as $parameter)
180 if ($matches[$parameter] ===
'' && $this->options && $this->options->hasDefault($parameter))
183 $requestParameters[$parameter] = $this->options->getDefault($parameter);
187 $requestParameters[$parameter] = $matches[$parameter];
193 if (!empty($defaultValues = $this->options->getDefault()))
195 foreach ($defaultValues as $parameter => $defaultValue)
197 if (!in_array($parameter, $parametersList))
199 $requestParameters[$parameter] = $defaultValue;
204 return $requestParameters;
209 if ($uriPath === $this->
getUri())
211 $requestParameters = [];
215 if (!empty($defaultValues = $this->options->getDefault()))
217 foreach ($defaultValues as $parameter => $defaultValue)
219 $requestParameters[$parameter] = $defaultValue;
223 return $requestParameters ?:
true;