@param null $server

@return mixed
@throws \Exception
340206
public function getIp($server = null)
    {
        $server || $server = $this->_SERVER;

        if (is_null($this->ip) && isset($server['REMOTE_ADDR'])) {
            $this->setIp($server['REMOTE_ADDR']);
        }

        return $this->ip;
    }
577893
protected static function resolveHostPort($server)
    {
        if (isset($server['HTTP_HOST'])) {
            $host = $server['HTTP_HOST'];
        } elseif (isset($server['SERVER_NAME'])) {
            $host = $server['SERVER_NAME'];
        } else {
            throw new InvalidArgumentException(
                'Undefined HTTP host in server params'
            );
        }

        $port = null;

        if (isset($server['SERVER_PORT'])) {
            $port = $server['SERVER_PORT'];
        }

        if (preg_match('/:(\d+)$/', $host, $matches)) {
            $host = rtrim($host, ":{$matches[1]}");
            $port = (int)$matches[1];
        }

        return $host . ($port !== null ? ":$port" : '');
    }
333596
public function getServer()
    {
        if ($this->server === null) {
            if (isset($_SERVER['argv'])) {
                $this->server = $_SERVER['argv'];
                array_shift($this->server);
            } else {
                $this->server = [];
            }
        }

        return $this->server;
    }
528252
protected function getLdapUrl($server = null)
    {
        $server = $server ?: $this->serverPool->getServer();
        $ldapUrl = ($this->config->getUseSsl() ? 'ldaps' : 'ldap').'://'.$server.':'.$this->config->getPort();

        return [$ldapUrl, $server];
    }
125165
public function getRequest()
    {
        if (isset($_SERVER['REQUEST_METHOD'])) {
            return new PhpRequest(
                empty($_SESSION) ? [] : $_SESSION,
                empty($_COOKIE) ? [] : $_COOKIE,
                getallheaders(),
                $_SERVER,
                static::getInputParams($_SERVER, $_POST)
            );
        }

        return new NullRequest();
    }
234667
public function sapiUri($server = null)
    {
        return new Messages\URI\SAPI(
            $server !== null ? $server : $_SERVER
        );
    }
1200062
public function parseMethod(array $server) {
        $method = array_get($server, 'REQUEST_METHOD');

        if (array_has($server, '_method')) {
            $_method = strtoupper(array_get($server, '_method'));

            if (array_contains(HttpRequestMethod::getMethods(), $_method)) {
                return $_method;
            }
        }

        return $method;
    }
970276
public function get($key = null)
    {
        //argument 1 must be a string or null
        Argument::i()->test(1, 'string', 'null');

        if (!self::$session) {
            Exception::i()->setMessage(self::ERROR_NOT_STARTED)->trigger();
        }

        if (is_null($key)) {
            return $_SESSION;
        }

        if (isset($_SESSION[$key])) {
            return $_SESSION[$key];
        }

        return null;
    }
368589
protected function getHotReloadProcess($server)
    {
        $recursively = Arr::get($this->config, 'hot_reload.recursively');
        $directory = Arr::get($this->config, 'hot_reload.directory');
        $filter = Arr::get($this->config, 'hot_reload.filter');
        $log = Arr::get($this->config, 'hot_reload.log');

        $cb = function (FSEvent $event) use ($server, $log) {
            $log ? $this->info(FSOutput::format($event)) : null;
            $server->reload();
        };

        return (new FSProcess($filter, $recursively, $directory))->make($cb);
    }
673334
protected function findAuthHeader(array $server) {
        if (array_has($server, 'HTTP_AUTHORIZATION')) {
            return array_get($server, 'HTTP_AUTHORIZATION');
        } else if (array_has($server, 'REDIRECT_HTTP_AUTHORIZATION')) {
            return array_get($server, 'REDIRECT_HTTP_AUTHORIZATION');
        }

        return null;
    }
1268169
public function getServer(string $name = null)
    {
        if (is_null($name)) {
            return $this->get('server');
        }

        return $this->get('server', $name);
    }
108875
protected function server($key = null, $default = null, $deep = false)
    {
        return $key === null ? $this->getServer()->all() : $this->getServer()->get($key, $default, $deep);
    }
56681
public function getConnection($connection, $server = null)
    {
        $connectionKey = $this->credentials->sanitizeConnection($connection, $server);
        $handle = $connectionKey->toHandle();

        $connections = $this->getConnections();
        if (!$connections->has($handle)) {
            throw new ConnectionException('Invalid connection: '.$handle);
        }

        return $connections[$handle];
    }
120256
private function getFromRemoteHostServer()
    {
        if (empty($remoteHost = $this->request->server('REMOTE_HOST')))
            return null;

        $remoteHost = explode('.', $remoteHost);
        $locale     = strtolower(end($remoteHost));

        return $this->isSupported($locale) ? $locale : null;
    }
851892
public function connect($server = null)
    {

        if (empty($server)) {
            $server = $this->query['server'];
        }

        /** @TODO Throw an exception here */
        if (empty($server)) {
            return false;
        }

        $port = $this->query['server_port'];

        $parsed = $this->parseServer($server);
        $server = $parsed['host'];

        if (array_key_exists('port', $parsed)) {
            $port = $parsed['port'];
        }

        // Enter connection attempt loop
        $retry = 0;

        while ($retry <= $this->retry) {
            // Set query status
            $this->query['status'] = 'ready';

            // Connect to whois port
            $ptr = @fsockopen($server, $port, $errno, $errstr, $this->stimeout);

            if ($ptr > 0) {
                $this->query['status'] = 'ok';
                return $ptr;
            }

            // Failed this attempt
            $this->query['status'] = 'error';
            $this->query['error'][] = $errstr;
            $retry++;

            // Sleep before retrying
            sleep($this->sleep);
        }

        // If we get this far, it hasn't worked
        return false;
    }
879617
public function parseRequest(array $server, IHttpRequest $request = null) {
        if ( ! $request instanceof IHttpRequest) {
            $request = $this->createRequest();
        }

        $this->setMethod($request, $server);
        $this->setUrl($request, $server);
        $this->setHeaders($request, $server);
        $this->setProtocol($request, $server);
        $this->setContent($request);
        $this->setServerGlobal($request, $server);

        return $request;
    }
1237756
function setServer($server)
    {
        $this->server = new DataEntity(
            $this->_normalizeServer($server)
        );
        
        return $this->server;
    }