1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 19:04:03 +00:00

minor improvements for phpstan

This commit is contained in:
Samuel Štancl 2022-09-01 19:06:54 +02:00
parent 62d19c5f5d
commit f941df3a82
4 changed files with 18 additions and 9 deletions

View file

@ -58,11 +58,15 @@ if (! function_exists('global_cache')) {
if (! function_exists('tenant_route')) {
function tenant_route(string $domain, string $route, array $parameters = [], bool $absolute = true): string
{
// replace the first occurrence of the hostname fragment with $domain
$url = route($route, $parameters, $absolute);
$hostname = parse_url($url, PHP_URL_HOST);
$position = strpos($url, $hostname);
return substr_replace($url, $domain, $position, strlen($hostname));
/**
* The original hostname in the generated route.
*
* @var string $hostname
*/
$hostname = parse_url($url, PHP_URL_HOST);
return (string) str($url)->replace($hostname, $domain);
}
}