Simplify logic in RedirectRule when checking geolocation conditions

This commit is contained in:
Alejandro Celaya
2024-11-15 09:00:59 +01:00
parent b5ff568651
commit 6aaea2ac26
3 changed files with 14 additions and 34 deletions

View File

@@ -293,5 +293,10 @@ function ipAddressFromRequest(ServerRequestInterface $request): string|null
function geolocationFromRequest(ServerRequestInterface $request): Location|null
{
return $request->getAttribute(Location::class);
$geolocation = $request->getAttribute(Location::class);
if ($geolocation !== null && ! $geolocation instanceof Location) {
// TODO Throw exception
}
return $geolocation;
}