@param string|null $host

@return array
436150
public function getBackendLocales($host = null)
    {
        $host = $this->getRealHost($host);

        if (isset($this->hosts[$host]['locales'])) {
            return array_values($this->hosts[$host]['locales']);
        }

        return parent::getBackendLocales();
    }
420118
public function findServer($host, $port)
    {
        if (isset($this->serversByHosts[$host][$port])) {
            return $this->serversByHosts[$host][$port];
        }
        
        return null;
    }
956055
private function getHostConfigurations($hosts)
    {
        $hostConfigurations = array();
        foreach ($hosts as $name => $settings) {
            $host = $settings['host'];
            // Set the key of the host as id.
            $hostConfigurations[$host]['id'] = $name;

            foreach ($settings as $setting => $data) {
                if ($setting === 'locales') {
                    $hostConfigurations[$host]['locales_extra'] = $this->getLocalesExtra($data);
                    $data = $this->getHostLocales($data);
                    $hostConfigurations[$host]['reverse_locales'] = array_flip($data);
                }
                $hostConfigurations[$host][$setting] = $data;
            }
        }

        return $hostConfigurations;
    }
346427
public function host($host = null)
    {
        if (func_num_args() === 0) {
            $scheme = $this->_classes['scheme'];
            $port = $scheme::port($this->_scheme) !== $this->_port ? $this->_port : null;
            return ($port !== null ? "{$this->_host}:{$port}" : $this->_host);
        }
        if (strpos($host, ':')) {
            list($host, $port) = explode(':', $host);
            $this->port($port);
        }
        $this->_host = $host;
        $headers = $this->headers();
        $headers->prepend('Host', $this->host());
        return $this;
    }
811915
public function getUrlForHost($host)
    {
        $newUrl = clone $this;
        $newUrl->_fragments['host'] = $host;
        $newUrl->_inputString = $newUrl->__toString();

        return $newUrl;
    }
1234019
public static function parse(string $host): HostInterface
    {
        if (!self::myParse($host, $hostname, $ipAddress, $error)) {
            throw new HostInvalidArgumentException($error);
        }

        return new self($hostname, $ipAddress);
    }
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;
    }
1342003
public function load($environment = null)
    {
        if ($environment == 'production') $environment = null;

        if (! $this->files->exists($path = $this->getFile($environment))) {
            return array();
        } else {
            return $this->files->getRequire($path);
        }
    }
936999
public function getReason($host)
    {
        $hostcdNode = $this->getHostcd($host);
        $node = $this->getFirst('host:reason', $hostcdNode);

        return $node === null ? null : $node->nodeValue;
    }
241337
private function filterHost(string $host): string
    {
        return preg_replace_callback(
            '/(?:[^'.self::UNRESERVED.self::SUB_DELIMS.':%\[\]]+|%(?![A-Fa-f0-9]{2}))/',
            function (array $match) {
                return rawurlencode($match[0]);
            },
            $host
        );
    }
1182848
public function connect(string $host = null): self
    {
        // link is already active?
        if ($host && isset($this->links[$host])) {
            return $this;
        }

        // set type as single as default
        $type = Link::TYPE_SINGLE;

        // get config as array
        $config = $this->config->toArray();

        // get database directives from given config
        $database = ($config['database'] ?? []);

        // is master/slave active?
        if (true === $this->config->get('sharding')) {
            $master = ($database['master'] ?? []);
            $slaves = ($database['slaves'] ?? []);
            switch ($host) {
                // act: master as default
                case null:
                case Link::TYPE_MASTER:
                    $type = Link::TYPE_MASTER;
                    $database = array_merge($database, $master);
                    break;
                //  act: slave
                case Link::TYPE_SLAVE:
                    $type = Link::TYPE_SLAVE;
                    if (!empty($slaves)) {
                        $database = array_merge($database, Util::arrayRand($slaves));
                    }
                    break;
                default:
                    // given host is master's host?
                    if ($host == ($master['host'] ?? '')) {
                        $type = Link::TYPE_MASTER;
                        $database = array_merge($database, $master);
                    } else {
                        // or given host is slaves's host?
                        $type = Link::TYPE_SLAVE;
                        foreach ($slaves as $slave) {
                            if (isset($slave['host']) && $slave['host'] == $host) {
                                $database = array_merge($database, $slave);
                                break;
                            }
                        }
                    }
            }
        }

        // remove unused parts
        unset($config['database'], $database['master'], $database['slaves']);

        // merge configs
        $config = array_merge($config, $database);
        if (!isset($config['host'], $config['name'], $config['username'], $config['password'])) {
            throw new InvalidConfigException(
                'Please specify all needed credentials (host, name, username, password) for a link!');
        }

        // use host as a key for link stack
        $host = $config['host'];

        // create a new link if not exists
        if (!isset($this->links[$host])) {
            $link = new Link($this->database, new Config($config), $type, $host);
            $link->open();
            // add link to links stack
            $this->setLink($host, $link);
        }

        return $this;
    }
110621
public function getAllKillRequests($host = null)
    {
        $collection = $this->getAllRunningSchedules($host);
        $collection->addFieldToFilter('kill_request', array('lt' => strftime('%Y-%m-%d %H:%M:00', time()+60)));
        return $collection;
    }
675980
public function hasHost(string $host): bool
	{
		$host = Host::filter($host);
		return $this->offsetExists($host);
	}
694746
public function withHost($host)
    {
        $uri = $this->getUri()->withHost($host);

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

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

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

        return $this;
    }
542185
public function getByRequestParts(
        string $host,
        string $method,
        RequestParts $requestParts
    ): array {
        $json = json_encode($requestParts->getParameters()['json']);
        $formattedUrl = rtrim($host, '/').'/'.ltrim($requestParts->getUrl(), '/');
        $method = strtoupper($method);
        $headers = [];
        foreach ($requestParts->getParameters()['headers'] ?? [] as $header => $value) {
            $headers[] = "$header: $value";
        }

        $c = curl_init();
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($c, CURLOPT_URL, $formattedUrl);
        curl_setopt($c, CURLOPT_HEADER, false);
        curl_setopt($c, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($c, CURLOPT_ENCODING, 'gzip, deflate');

        if (!in_array($method, ['GET', 'HEAD'])) {
            curl_setopt($c, CURLOPT_POSTFIELDS, $json);
            $headers[] = 'Content-Type: application/json';
            $headers[] = 'Content-Length: '.strlen($json);
        }

        curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
        $content = curl_exec($c);
        $responseCode = curl_getinfo($c, CURLINFO_HTTP_CODE);
        curl_close($c);

        if (
            'HEAD' !== $method &&
            false === $content
        ) {
            throw ConnectionException::buildConnectExceptionByUrl($requestParts->getUrl());
        }

        return [
            'code' => (int) $responseCode,
            'body' => empty($content)
                ? []
                : json_decode($content, true),
        ];
    }
1108076
public function create($host = null) : HttpServerDoc
    {
        $serverDoc = new HttpServerDoc();
        if (null !== $this->jsonRpcEndpoint) {
            $serverDoc->setEndpoint($this->jsonRpcEndpoint);
        }
        if (null !== $host) {
            $serverDoc->setHost($host);
        }

        $this->appendMethodsDoc($serverDoc);

        $event = new ServerDocCreatedEvent($serverDoc);
        $this->dispatcher->dispatch($event::EVENT_NAME, $event);

        return $serverDoc;
    }