remove host from hosts file.

@param string The $host to be removed to the hosts file

@throws RuntimeException if host does not exists or cant write to file

@return bool
333210
public function remove($host)
    {
        $this->validHost($host);

        if (!$this->check($host)) {
            throw new \RuntimeException('Host does not exists in the file');
        }

        $this->backup();

        $tmpFilePath = $this->filepath.'.tmp';

        $tmpFile = new \SplFileObject($tmpFilePath, 'w+');

        $this->file->rewind();

        while (!$this->file->eof()) {
            $pattern = '/\b'.$host.'\b/i';
            if (!preg_match($pattern, $this->file->current())) {
                $tmpFile->fwrite($this->file->current());
            }
            $this->file->next();
        }

        copy($tmpFilePath, $this->filepath);
        unlink($tmpFilePath);

        return true;
    }
1298413
protected function host_explicitly_blocked($host) {
        $blockedhosts = $this->get_blacklisted_hosts_by_category();
        $domainhostsblocked = array_merge($blockedhosts['domain'], $blockedhosts['domainwildcard']);
        return ip_utils::is_domain_in_allowed_list($host, $domainhostsblocked);
    }
1175673
private function formatHost(?string $host): ?string
    {
        if (null === $host || '' === $host) {
            return $host;
        }

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

        return $this->formatIp($host);
    }
1105
public function setHost($host)
    {
        if (! (self::_isHostname($host) || self::_isIpAddress($host))) {

            throw new InvalidArgumentException("Invalid host ($host)");
        }

        $this->_host = strtolower(trim($host));
    }
735095
private function checkHost(string $host): bool
    {
        return '' !== $host && ($this->checkMX($host) || (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA')));
    }
325236
@Override
    public synchronized boolean removeHost(Host host, boolean refresh) {
        HostConnectionPool<CL> pool = hosts.remove(host);
        if (pool != null) {
            topology.removePool(pool);
            rebuildPartitions();
            monitor.onHostRemoved(host);
            pool.shutdown();
            return true;
        }
        else {
            return false;
        }
    }
990050
public function blockOne($host)
    {
        return $this->exists($host)
            ? $this->updateOne($host)
            : $this->addOne($host);
    }
339604
public function remove($path)
    {
        list($name, $path) = $this->splitPath($path);

        if (empty($path)) {
            throw new RuntimeException('The root node of config is not writable');
        }

        return $this->load($name)->remove($path);
    }
1194065
public function execute(InputInterface $input, OutputInterface $output)
    {
        $host = $input->getArgument('host');

        $remove = $this->hostFile->remove($host);

        $output->writeLn("$host was removed from file.");
    }
411479
public function setHost($host)
    {
        if ($this->validateHost($host) === false) {
            throw new Zend_Uri_Exception("Host \"$host\" is not a valid HTTP host");
        }

        $oldHost     = $this->_host;
        $this->_host = $host;

        return $oldHost;
    }
881844
public function setHost($host)
    {
        if (strpos($host, ':') === false) {
            $this->host = $host;
        } else {
            list($host, $port) = explode(':', $host);
            $this->host = $host;
            $this->setPort($port);
        }

        return $this;
    }
815735
public function setHost($host)
    {
        $this->host = $host;
        if (strpos($host, '/') !== false || strpos($host, '?') !== false) {
            if (strpos($host, 'http') === false) {
                $host = 'https://' . $host;
            }
            $url = parse_url($host);
            $this->host = $url['host'];

            if (isset($url['path'])) {
                $this->setPath($url['path']);
            }

            if (isset($url['query'])) {
                if (!isset($url['path'])) { // for example.org?query=string
                    $this->setPath('/');
                }
                $this->setQuery($url['query']);
            }
        }

        return $this;
    }
1019456
public function equals(HostInterface $host): bool
    {
        if ($this->getIPAddress() !== null && $host->getIPAddress() !== null) {
            return $this->getIPAddress()->equals($host->getIPAddress());
        }

        return $this->getHostname()->equals($host->getHostname());
    }
536907
protected static function filterHost($host)
    {
        if (! is_string($host)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid host; must be a string argument; received %s',
                (is_object($host) ? get_class($host) : gettype($host))
            ));
        }

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

        $this->host = $host;
    }
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;
    }
1132249
public function host($host = null)
    {
        $this->host = empty($host) ? null : $host;

        return $this->host;
    }