matchHosts

@param mixed $host
@param array $hosts

@access protected
@return boolean
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;
    }
378889
public function host($host = '') {
        if ($host) {
            $this->host = $host;
        }
        if (!$this->host) {
            $this->host = self::server('HTTP_HOST');
        }
        return $this->host;
    }
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;
    }
973295
protected boolean hostMatches(String registered, String requested) {
		if (matchSubdomains) {
			return registered.equals(requested) || requested.endsWith("." + registered);
		}
		return registered.equals(requested);
	}
1279701
public function disallowHost($host, $matchSubdomains = true)
	{
		$this->disallowedHosts[] = $host;

		if ($matchSubdomains && substr($host, 0, 1) !== '*')
		{
			$this->disallowedHosts[] = '*.' . $host;
		}
	}
569115
public function setHost($host)
    {
        if (substr($host, -1) === '/') {
            $host = substr($host, 0, strlen($host) - 1);
        }

        $this->host = $host;
    }
1132249
public function host($host = null)
    {
        $this->host = empty($host) ? null : $host;

        return $this->host;
    }
851909
public function assertHostIsNot($host)
    {
        $actual = parse_url($this->driver->getCurrentURL(), PHP_URL_HOST) ?? '';

        PHPUnit::assertNotEquals(
            $host, $actual,
            "Host [{$host}] should not equal the actual value."
        );

        return $this;
    }
750959
public function setHost(/* string */ $host) {
		// Close connection before changing host.
		if ($this->host !== $host) {
			$this->close();
			$this->host = $host;
		}
	}
1178532
public function removeHost($host)
    {
        if (isset($this->hosts[$host])) {
            unset($this->hosts[$host]);
        }

        return $this;
    }
1298132
public function addHost($host)
    {
        if (!isset($this->hosts[$host])) {
            $this->hosts[$host] = $host;
        }

        return $this;
    }
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;
        }
    }
1259502
public function isSameHost(string $host, array $globalConstraints): bool
    {
        if ($this->host === null) {
            return true;
        }

        if (\mb_strpos($this->host, '{') === false) {
            return $this->host === $host;
        }

        $regex = $this->extractInlineContraints($this->host, 'hostConstraints');

        $regex = \preg_replace('/\{(\w+?)\}/', '(?P<$1>[^.]++)', $regex);

        $constraints = \array_merge($globalConstraints, $this->hostConstraints);
        foreach ($constraints as $id => $regexRule) {
            $regex = \str_replace('<' . $id . '>[^.]++', '<' . $id . '>' . $regexRule, $regex);
        }
        $pattern = '#^' . $regex . '$#s';
        $matches = [];

        if (\preg_match($pattern, $host, $matches)) {
            \array_shift($matches);
            $this->saveHostParameters($matches);

            return true;
        }

        return false;
    }
1329581
public function isHost(string $host, bool $includeSubDomains = false) : bool
    {
        $thisHost = strtolower($this->host);
        $thatHost = strtolower($host);

        if (! $includeSubDomains) {
            return $thisHost === $thatHost;
        }

        $thisHost = explode('.', $thisHost);
        $thatHost = explode('.', $thatHost);

        return array_slice($thisHost, - count($thatHost)) === $thatHost;
    }
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;
    }
555006
private function matchHostPart($value, &$hostname, &$address) {
        $matches = [];
        $pattern = '~^(?P<name>[a-z0-9\-]+\.[a-z0-9\-\.]+)?\s*(\[(IPv[64])?(?P<addr>[a-f\d\.\:]+)\])?$~i';
        if (preg_match($pattern, $value, $matches)) {
            if (!empty($matches['name'])) {
                $hostname = $matches['name'];
            }
            if (!empty($matches['addr'])) {
                $address = $matches['addr'];
            }
            return true;
        }
        return false;
    }
1087394
public function getConfigForHost($host)
    {
        $matches = array();
        foreach ($this->configs as $config) {
            if (fnmatch($config['host'], $host)) {
                $matches[] = $config;
            }
        }
        if (count($matches) == 0) {
            throw new RuntimeException("Unable to find configuration for host '{$host}'");
        }
        usort($matches, function ($a, $b) {
            return strlen($a['host']) > strlen($b['host']);
        });
        $result = array();
        foreach ($matches as $match) {
            $result = array_merge($result, $match);
        }
        unset($result['host']);
        if (isset($result['identityfile'])) {
            $result['identityfile'] = $this->processPath($result['identityfile']);
        } else if (file_exists($file = $this->processPath($this->getIdentity()))) {
            $result['identityfile'] = $file;
        }

        return $result;
    }