aboutsummaryrefslogtreecommitdiffstats
path: root/Http.php
diff options
context:
space:
mode:
Diffstat (limited to 'Http.php')
-rw-r--r--Http.php41
1 files changed, 23 insertions, 18 deletions
diff --git a/Http.php b/Http.php
index f826b1e..0d8f1f3 100644
--- a/Http.php
+++ b/Http.php
@@ -712,36 +712,41 @@ class Http extends Generic implements \Hoa\Core\Parameter\Parameterizable {
*/
public function getSubdomain ( $withSuffix = true ) {
- $domain = static::getDomain();
+ static $subdomain = null;
- if(empty($domain))
- return null;
+ if(null === $subdomain) {
- if($domain == long2ip(ip2long($domain)))
- return null;
+ $domain = static::getDomain();
- if(2 > substr_count($domain, '.', 1))
- return null;
+ if(empty($domain))
+ return null;
- $subdomain = substr(
- $domain,
- 0,
- strrpos(
+ if($domain == long2ip(ip2long($domain)))
+ return null;
+
+ if(2 > substr_count($domain, '.', 1))
+ return null;
+
+ $subdomain = substr(
$domain,
- '.',
- -(strlen($domain) - strrpos($domain, '.') + 1)
- )
- );
+ 0,
+ strrpos(
+ $domain,
+ '.',
+ -(strlen($domain) - strrpos($domain, '.') + 1)
+ )
+ );
+ }
if(true === $withSuffix)
return $subdomain;
$suffix = $this->getSubdomainSuffix();
- if(null !== $suffix)
- $subdomain = substr($subdomain, 0, -strlen($suffix) - 1);
+ if(null === $suffix)
+ return $subdomain;
- return $subdomain;
+ return substr($subdomain, 0, -strlen($suffix) - 1);
}
/**