scheme(); if ($scheme === null || $scheme === '') { throw new InvalidArgumentException("URL has no scheme: {$url}"); } if (! in_array($scheme, ['http', 'https'], true)) { throw new InvalidArgumentException("Invalid URL scheme: {$scheme}"); } $host = $uri->host(); if ($host === null || $host === '') { throw new InvalidArgumentException("URL has no host: {$url}"); } if (filter_var(trim($host, '[]'), FILTER_VALIDATE_IP) !== false) { throw new InvalidArgumentException("IP literal hosts not allowed: {$host}"); } return strtolower($host); } }