/** * Returns the expected uri path to validate against the route path. * @param \Brickoo\Component\Routing\Route\Route $route * @param array $pathParameters the path parameters to use * @throws \Brickoo\Component\Routing\Route\Exception\RouteRequiredParametersMissingException * @return string the uri path expected */ private function getExpectedRoutePath(Route $route, $pathParameters) { $routePath = $route->getPath(); $pathParameters = array_merge($route->getDefaultValues(), $pathParameters); foreach ($pathParameters as $parameter => $value) { $routePath = str_replace("{" . $parameter . "}", $value, $routePath); } $matches = []; if (preg_match_all("~(\\{(?<missingParameters>[\\w]+)\\})~", $routePath, $matches) > 0) { throw new RouteRequiredParametersMissingException($route->getName(), $matches["missingParameters"]); } return $routePath; }