Transforms $_SERVER array.

@param array $server
@param array $header

@return array
353077
protected static function transformServerParameters(array $server, array $header)
    {
        $__SERVER = [];

        foreach ($server as $key => $value) {
            $key = strtoupper($key);
            $__SERVER[$key] = $value;
        }

        foreach ($header as $key => $value) {
            $key = str_replace('-', '_', $key);
            $key = strtoupper($key);

            if (! in_array($key, ['REMOTE_ADDR', 'SERVER_PORT', 'HTTPS'])) {
                $key = 'HTTP_' . $key;
            }

            $__SERVER[$key] = $value;
        }

        return $__SERVER;
    }
386522
public function server(array $server)
    {
        foreach ((array) $server as $key => $value)
        {
            $string = strtolower(substr($key, 5));

            $key = str_replace('_', '-', $string);

            if (strpos($key, 'HTTP_') === 0)
            {
                $this->headers[$key] = $value;
            }
        }
    }
1103881
public function createServerRequestFromArray(array $server){
        $method     = $server["REQUEST_METHOD"] ?? "GET";

        return new ServerRequest(
            $method,
            (new UriFactory())->createFromServer($server),
            $server,
            self::getUploadedFiles($_FILES),
            $_COOKIE,
            $_GET,
            self::getProtocolVersion($server)
        );
    }
100988
public static function make(array $server = null)
    {
        if (empty($server)) {
            $server = $_SERVER;
        }

        if (isset($server['REQUEST_URI'])) {
            return parse_url($server['REQUEST_URI'], PHP_URL_QUERY);
        }
    }
149571
private function convertToArray($server)
    {
        $activeServer = [
            'id' => $server->getId(),
            'ip' => $server->getIp(),
            'lastFrontendUsage' => $server->getLastFrontendUsage(),
            'lastAdminUsage' => $server->getLastAdminUsage()
        ];
        return $activeServer;
    }
970773
private function processServerVariables(array $server)
    {
        foreach ($server as $key => $value) {
            $this->server[$key] = $value;

            if (strpos($key, 'HTTP_') === 0) {
                $key = str_replace('_', '-', substr($key, 5));

                $this->headers[$key] = $value;
            }
        }

        $uri     = $server['REQUEST_URI'];
        $uriPath = parse_url($uri, PHP_URL_PATH);

        $this->server['REQUEST_URI']      = $uri;
        $this->server['REQUEST_URI_PATH'] = $uriPath;

        $this->isEncrypted = !(empty($server['HTTPS']) || strcasecmp($server['HTTPS'], 'off') === 0);

        $this->server['SERVER_PROTOCOL'] = substr($server['SERVER_PROTOCOL'], -3);

        if (isset($server['CONTENT_LENGTH'])) {
            $this->headers['CONTENT-LENGTH'] = $server['CONTENT_LENGTH'];
        }

        if (isset($server['CONTENT_TYPE'])) {
            $this->headers['CONTENT-TYPE'] = $server['CONTENT_TYPE'];
        }
    }
806348
public static function make(array $server = null)
    {
        if (empty($server)) {
            $server = $_SERVER;
        }

        if (isset($server['SERVER_PROTOCOL'])) {
            return $server['SERVER_PROTOCOL'];
        }

        return 'HTTP/1.1';
    }
1356649
protected function transformHeadersToServerVars(array $headers): array
    {
        $server = [];
        $prefix = 'HTTP_';

        foreach ($headers as $name => $value) {
            $name = str_replace(strtoupper($name), '-', '_');

            if ($name !== 'CONTENT_TYPE' && ! starts_with($name, $prefix)) {
                $name = $prefix.$name;
            }

            $server[$name] = $value;
        }

        return $server;
    }
1107778
private function normalizeHeaders($headers)
    {
        $normalized = [];
        foreach ($headers as $name => $value) {
            $name              = $this->normalizeName($name);
            $normalized[$name] = $this->normalizeData($name, $value);
        }

        return $normalized;
    }
212676
private static function getHeadersArray(array $serverVars): array
    {
        $headersArray = [];

        if (function_exists('getallheaders')) {
            /** @noinspection PhpComposerExtensionStubsInspection */
            return getallheaders();
        }

        foreach ($serverVars as $name => $value) {
            if (substr($name, 0, 5) === 'HTTP_') {
                $headersArray[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
            }
        }

        return $headersArray;
    }
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;
    }
186904
public function server(array $server)
    {
        parent::server($server);

        $this->server = $server;

        $this->method = $server['REQUEST_METHOD'];

        $this->target = $server['REQUEST_URI'];

        $http = 'https://';

        if (! isset($server['HTTPS']) || $server['HTTPS'] === 'off')
        {
            $http = 'http://';
        }

        $link = $http . $server['SERVER_NAME'];

        $port = $server['SERVER_PORT'] . $this->target;

        $this->uri = new Uri($link . ':' . $port);

        return $this;
    }
847482
public static function make(array $server = null)
    {
        if (empty($server)) {
            $server = $_SERVER;
        }
        $headers = [];
        $content = [
            'CONTENT_TYPE'   => 'Content-Type',
            'CONTENT_LENGTH' => 'Content-Length',
            'CONTENT_MD5'    => 'Content-Md5',
        ];
        foreach ($server as $key => $value) {
            if (substr($key, 0, 5) === 'HTTP_') {
                $key = substr($key, 5);
                if (! isset($content[$key]) || ! isset($server[$key])) {
                    $key = str_replace('_', ' ', $key);
                    $key = ucwords(strtolower($key));
                    $key = str_replace(' ', '-', $key);

                    $headers[$key] = $value;
                }
            } elseif (isset($content[$key])) {
                $headers[$content[$key]] = $value;
            }
        }

        return $headers;
    }
1109569
protected function flattenHeaders(array $headers)
    {
        foreach ($headers as &$value) {
            $value = is_array($value) ? end($value) : $value;
        }
        
        return $headers;
    }
1175438
private static function aggregateHeaderFromServer($server = [])
    {
        $header = [];

        if (isset($server['HTTP_HOST'])) {
            $header['Host'] = $server['HTTP_HOST'];
        }

        if (isset($server['HTTP_USER_AGENT'])) {
            $header['User-Agent'] = $server['HTTP_USER_AGENT'];
        }

        if (isset($server['HTTP_CONNECTION'])) {
            $header['Connection'] = $server['HTTP_CONNECTION'];
        }

        if (isset($server['HTTP_ACCEPT_ENCODING'])) {
            $header['Accept-Encoding'] = $server['HTTP_ACCEPT_ENCODING'];
        }

        if (isset($server['HTTP_ACCEPT_LANGUAGE'])) {
            $header['Accept-Language'] = $server['HTTP_ACCEPT_LANGUAGE'];
        }

        if (isset($server['HTTP_CACHE_CONTROL'])) {
            $header['Cache-Control'] = $server['HTTP_CACHE_CONTROL'];
        }

        if (isset($server['HTTP_ACCEPT'])) {
            $header['Accept'] = $server['HTTP_ACCEPT'];
        }

        return $header;
    }
7972
function getHeader($header)
    {
        if (! $this->hasHeader($header)) {
            if (strtolower($header) === 'host'
                && ($this->uri && $this->uri->getHost())
            )
                return array($this->_getHostFromUri());

            return array();
        }

        $header = $this->_c_headerNormalized[strtolower($header)];
        $value  = $this->headers[$header];
        $value  = is_array($value) ? $value : array($value);
        return $value;
    }
799226
protected function configureServer($server, array $config)
    {
        if ($handler = $this->parseEventHandler($config)) {
            $server->setEventHandler($handler);
        }

        if (isset($config['listens']) && $config['listens']) {
            $this->configureServerSockets($server, $config['listens']);
        }

        if (isset($config['processes']) && $config['processes']) {
            $this->configureProcesses($server, $config['processes']);
        }

        return $server;
    }