Process a request header and return the one with preferred quality

@param array  $qualityParts
@param string $name

@return string
161489
protected function getPreferredQuality(array $qualityParts, $name)
    {
        $i = 0;
        $quality = 0;
        $selectedName = '';

        foreach ($qualityParts as $accept) {
            if ($i == 0) {
                $quality = $accept['quality'];
                $selectedName = $accept[$name];
            } else {
                $acceptQuality = $accept['quality'];
                $preferredQuality = ($quality < $acceptQuality);

                if ($preferredQuality === true) {
                    $quality = $acceptQuality;
                    $selectedName = $accept[$name];
                }
            }
            $i++;
        }

        return $selectedName;
    }
56442
public static function post(string $name)
    {
        return (isset($_POST[$name]) && $_POST[$name] != '') ? $_POST[$name] : '';
    }
817691
public function get_header($name = null)
	{
		if (func_num_args())
		{
			return isset($this->headers[$name]) ? $this->headers[$name] : null;
		}
		else
		{
			return $this->headers;
		}
	}
1347665
public static function clean_page_url($name)
    {
        $name = str_replace(array(' '), '_', $name);

        $name = self::trim_extension_off($name);
        $name = self::trim_sort_number($name);

        if (preg_match('/^[\/]?index[\/]?/', $name)) {
            return '';
        }

        return strtolower($name);
    }
140613
public function findComponentByName($name)
    {
        if (isset($this->page->components[$name])) {
            return $this->page->components[$name];
        }

        if (isset($this->layout->components[$name])) {
            return $this->layout->components[$name];
        }

        $partialComponent = $this->partialStack->getComponent($name);
        if ($partialComponent !== null) {
            return $partialComponent;
        }

        return null;
    }
726535
public function getHeader($name) {
		$varKey = 'HTTP_' . str_replace('-', '_', mb_strtoupper($name));
		if (isset($this->serverVars[$varKey])) {
			return $this->serverVars[$varKey];
		}
		
		if (function_exists('apache_request_headers')) {
			$requestHeaders = apache_request_headers();
			if (isset($requestHeaders[$name])) {
				return trim($requestHeaders[$name]);
			}
		}
		
		if (function_exists('getallheaders')) {
			$requestHeaders = getallheaders();
			if (isset($requestHeaders[$name])) {
				return trim($requestHeaders[$name]);
			}
		}
		
		return null;
	}
624675
public OkRequest<T> partHeader(final String name, final String value) throws IOException {
        return send(name).send(": ").send(value).send(CRLF);
    }
682946
public function getHeader($name){
        $headers= $this->getHeaders();
        if(isset($headers[$name])){
            return $headers[$name];
        }else{
            return NULL;
        }
    }
286451
public function get(string $name): ?string
    {
        $key = strtolower($name);
        if (!isset($this->headers[$key])) {
            return null;
        }

        return $this->headers[$key][1];
    }
1328228
public function generateRequest($name)
    {
        if (!$content = $this->getRequestContent($name)) {
            return '';
        }

        $path = app_path('Http/Requests/'.implode('/', $this->sectionSegmentsStudly).'/'.studly_case($name).'.php');

        if (is_file($path)) {
            return '';
        }

        $this->createMissingDirs($path);

        return file_put_contents($path, $content) !== false ? $path : '';
    }
1175159
public static function getPartial($name)
    {
        if (isset(self::$partials[$name])) {
            return self::$partials[$name];
        }
        
        return null;
    }
776366
protected function getRequestContent($name)
    {
        if (!$stub = $this->getRequestStub($name)) {
            return '';
        }

        $namespace = $this->appNs.'\Http\Requests\\'.implode('\\', $this->sectionSegmentsStudly);

        return strtr($stub, array_merge($this->getCommonReplacements(), [
            '{{namespace}}' => $namespace,
        ]));
    }
116666
public function getPost(string $name) : ?string
    {
        $r = null;
        if ($this->contentType === "multipart/form-data" ||
            $this->contentType === "application/x-www-form-urlencoded") {
            $r = ((isset($this->parsedBody[$name]) === true) ? (string)$this->parsedBody[$name] : null);
        }
        return $r;
    }
372994
private function failsHeaderFor(MessagePart $part, $type, $name, $header)
    {
        $headerValue = null;
        
        static $map = [
            'content-type' => 'getContentType',
            'content-disposition' => 'getContentDisposition',
            'content-transfer-encoding' => 'getContentTransferEncoding',
            'content-id' => 'getContentId'
        ];
        $lower = strtolower($name);
        if (isset($map[$lower])) {
            $headerValue = call_user_func([$part, $map[$lower]]);
        } elseif (!($part instanceof MimePart)) {
            return ($type === static::FILTER_INCLUDE);
        } else {
            $headerValue = $part->getHeaderValue($name);
        }
        
        return (($type === static::FILTER_EXCLUDE && strcasecmp($headerValue, $header) === 0)
            || ($type === static::FILTER_INCLUDE && strcasecmp($headerValue, $header) !== 0));
    }
77131
protected function getFullyQualifiedName($name)
    {
        if ($name instanceof FullyQualifiedName) {
            return \implode('\\', $name->parts);
        } elseif ($name instanceof Name) {
            $name = $name->parts;
        } elseif (!\is_array($name)) {
            $name = [$name];
        }

        return \implode('\\', \array_merge($this->namespace, $name));
    }
599140
protected function getComponent(string $name)
    {
        if (!is_object($this->components[$name])) {
            $this->components[$name] = $this->createComponent($name);
        }

        return $this->components[$name];
    }
1008563
private function getSegments($name)
    {
        if (preg_match('/^(?P<base>[^[]+)(?P<extra>(\[.*)|$)/', $name, $m)) {
            $segments = [$m['base']];
            while (!empty($m['extra'])) {
                $extra = $m['extra'];
                if (preg_match('/^\[(?P<segment>.*?)\](?P<extra>.*)$/', $extra, $m)) {
                    $segments[] = $m['segment'];
                } else {
                    $segments[] = $extra;
                }
            }

            return $segments;
        }

        return [$name];
    }