Psr7Middlewares\Middleware\Www::canAddWww PHP Метод

canAddWww() приватный Метод

Returns false if: - the host is "localhost" - the host is a ip - the host has already a subdomain, for example "subdomain.example.com".
private canAddWww ( string $host ) : boolean
$host string
Результат boolean
    private function canAddWww($host)
    {
        if (empty($host) || filter_var($host, FILTER_VALIDATE_IP)) {
            return false;
        }
        $host = explode('.', $host);
        switch (count($host)) {
            case 1:
                //localhost
                return false;
            case 2:
                //example.com
                return true;
            case 3:
                //example.co.uk
                if ($host[1] === 'co') {
                    return true;
                }
            default:
                return false;
        }
    }