Validate and Filter host value
@param string $host
@return string normalized value
185927
function _filterHost($host)
    {
        if (strstr($host, ':') !== false)
            throw new \InvalidArgumentException('Host name can`t contains port number.');

        $host = strtolower($host);
        return $host;
    }
1267551
protected function setHost($host)
    {
        $this->uriString = null;

        $this->host = (string) $host;

        return $this;
    }
800081
public function setHost($host)
    {
        if (substr($host, -1) === '/') {
            $host = substr($host, 0, -1);
        }

        $headers = $this->getConfig('headers');
        $headers['Host'] = $host;
        $this->setConfigOption('headers', $headers);

        if (strpos('/', $host) === false) {
            $host = 'https://' . $host;
        }
        $this->setConfigOption('base_uri', $host);

        return $this;
    }
936999
public function getReason($host)
    {
        $hostcdNode = $this->getHostcd($host);
        $node = $this->getFirst('host:reason', $hostcdNode);

        return $node === null ? null : $node->nodeValue;
    }
1153139
private function cleanHost($host)
    {
        // communicate via http by default if none is assigned
        if (strpos($host, 'http://') === false || strpos($host, 'https://')) {
            $host = 'http://' . $host;
        }

        // remove / at the end
        $host = rtrim($host, '/');

        return $host;
    }
1175673
private function formatHost(?string $host): ?string
    {
        if (null === $host || '' === $host) {
            return $host;
        }

        if ('[' !== $host[0]) {
            return $this->formatRegisteredName($host);
        }

        return $this->formatIp($host);
    }
1267745
public function getHostGroupsByHost(Host $host)
    {
        return array_values(
            array_filter(
                $this->hostGroups,
                function ($g) use ($host) {
                    return $g->hasHost($host);
                }
            )
        );
    }
694746
public function withHost($host)
    {
        $uri = $this->getUri()->withHost($host);

        /** @var static $clone */
        $clone = $this->withUri($uri);

        return $clone;
    }
990050
public function blockOne($host)
    {
        return $this->exists($host)
            ? $this->updateOne($host)
            : $this->addOne($host);
    }
463342
def valid_host(host):
    
    for part in host.split("."):
        if not _valid_host_part.match(part):
            return False

    return True
31783
public function make($host)
    {
        $host = $this->resolver->resolve($host, '/');
        $hash = md5($host);

        if (isset($this->instances[$hash])) {
            return $this->instances[$hash];
        }

        $validator = new Validator(
            $this->validator,
            new ResourceNormalizer
        );
        $instance = new Server(
            $this->capabilities->make($host),
            new Client(
                $this->loader->make($host),
                $this->serializer,
                $this->resolver,
                $validator,
                $this->dispatcher,
                $this->http
            )
        );
        $this->instances[$hash] = $instance;

        return $instance;
    }
506302
protected function matchHost($host, array $hosts)
    {
        foreach ($hosts as $trusted) {
            if (0 === strcmp($host, $trusted) || preg_match('#^'. $trusted .'#s', $host)) {
                return true;
            }
        }
        return false;
    }
1039417
public static function serializeHost($host)
    {
        if (is_int($host) || is_float($host)) {
            $string = self::serializeIPv4($host);
        } elseif (is_array($host)) {
            $string = '[' . self::serializeIPv6($host) . ']';
        } else {
            $string = (string)$host;
        }
        return $string;
    }
1220926
public function allowOne($host)
    {
        return $this->exists($host)
            ? $this->updateOne($host, false)
            : $this->addOne($host, false);
    }
203329
public static String normalizeHost(String host) {
        // if it is normalized IPv6 or could not be IPv6, return
        if (host.isEmpty() || host.charAt(0) == '[' || host.indexOf(':') < 0)
            return host;

        // normalize with [ ]
        return "[" + host + "]";
    }
420704
public function check($host)
    {
        $this->validHost($host);

        $host = trim($host);
        $valid = false; // init as false
        $this->file->rewind();

        while (!$this->file->eof()) {
            $pattern = '/\b'.$host.'\b/i';
            if (preg_match($pattern, $this->file->current())) {
                $valid = trim($this->file->current());
                break; // Once you find the string, you should break out the loop.
            }
            $this->file->next();
        }

        return $valid;
    }
615721
protected function setHostAndPort($host)
    {
        if (!str_contains($host, ':')) {
            $this->host = $host;
        } else {
            list($this->host, $this->port) = explode(':', $host);

            $this->port = (int) $this->port;
        }
    }