public function getRoute($name, array $params = []) { $route = $this->microWebFramework->getRouteName($name); $args = array_merge([$name], $params); if (empty($route)) { throw new MicroWebFrameException("The route '%s' doesn't exist.", $name); } $pattern = '/(\\{\\w*\\}|\\{(.+?):((\\{[^\\}]*\\})*|[^\\}])*\\})/'; preg_match_all($pattern, $route, $tabNameInfo); $nbNeededValue = count($tabNameInfo[0]); if ($nbNeededValue > func_num_args() - 1) { $nbValue = count($tabNameInfo[0]) - func_num_args() + 1; throw new MicroWebFrameException("You need to follow the pattern \"%s\" miss %s values.", $route, $nbValue); } if ($nbNeededValue <= 0) { return $this->getHttpName() . $this->fileEntryPoint . $route; } $nbArgs = count($tabNameInfo[0]); for ($i = 0; $i < $nbArgs; $i++) { $route = preg_replace($pattern, $args[$i + 1], $route, 1); } return $this->getHttpName() . $this->fileEntryPoint . $route; }