Nabble\SemaltBlocker\Domainparser::getHostname PHP Method

getHostname() public static method

public static getHostname ( string $url ) : string | false
$url string
return string | false
    public static function getHostname($url)
    {
        if (!isset(self::$cache[$url]['hostname'])) {
            self::$cache[$url]['hostname'] = self::parseUrl($url, PHP_URL_HOST);
        }
        return self::$cache[$url]['hostname'];
    }

Usage Example

 public function testHostnames()
 {
     foreach ($this->hostnames as $expectedHost => $samples) {
         foreach ($samples as $url) {
             $parsedHostname = Domainparser::getHostname($url);
             $this->assertNotFalse($parsedHostname, 'Parsed hostname for ' . $url . ' should not be false');
             $this->assertEquals($expectedHost, $parsedHostname, 'Expected hostname ' . $expectedHost . ', got ' . $parsedHostname . ' instead.');
         }
     }
 }
All Usage Examples Of Nabble\SemaltBlocker\Domainparser::getHostname