function Route::sanitizeRequirement
2 calls to Route::sanitizeRequirement()
- Route::addRequirements in vendor/
symfony/ routing/ Route.php - Route::setRequirement in vendor/
symfony/ routing/ Route.php
File
-
vendor/
symfony/ routing/ Route.php, line 442
Class
- Route
- A Route describes a route and its parameters.
Namespace
Symfony\Component\RoutingCode
private function sanitizeRequirement(string $key, string $regex) : string {
if ('' !== $regex) {
if ('^' === $regex[0]) {
$regex = substr($regex, 1);
}
elseif (str_starts_with($regex, '\\A')) {
$regex = substr($regex, 2);
}
}
if (str_ends_with($regex, '$')) {
$regex = substr($regex, 0, -1);
}
elseif (\strlen($regex) - 2 === strpos($regex, '\\z')) {
$regex = substr($regex, 0, -2);
}
if ('' === $regex) {
throw new \InvalidArgumentException(\sprintf('Routing requirement for "%s" cannot be empty.', $key));
}
return $regex;
}