1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 19:24: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

@ -15,11 +15,16 @@ class CrossDomainRedirect implements Feature
RedirectResponse::macro('domain', function (string $domain) {
/** @var RedirectResponse $this */
// Replace first occurrence of the hostname fragment with $domain
$url = $this->getTargetUrl();
/**
* The original hostname in the redirect response.
*
* @var string $hostname
*/
$hostname = parse_url($url, PHP_URL_HOST);
$position = strpos($url, $hostname);
$this->setTargetUrl(substr_replace($url, $domain, $position, strlen($hostname)));
$this->setTargetUrl((string) str($url)->replace($hostname, $domain));
return $this;
});