src/mako/http/request/Headers.php
protected function parseAcceptHeader(?string $headerValue): array
	{
		$groupedAccepts = [];

		if(empty($headerValue))
		{
			return $groupedAccepts;
		}

		// Collect acceptable values

		foreach(explode(',', $headerValue) as $accept)
		{
			$quality = 1;

			if(strpos($accept, ';'))
			{
				// We have a quality so we need to split some more

				[$accept, $quality] = explode(';', $accept, 2);

				// Strip the "q=" part so that we're left with only the numeric value

				$quality = substr(trim($quality), 2);
			}

			$groupedAccepts[$quality][] = trim($accept);
		}

		// Sort in descending order of preference

		krsort($groupedAccepts);

		// Flatten array and return it

		return array_merge(...array_values($groupedAccepts));
	}
protected function parseAcceptHeader(?string $headerValue): array
	{
		$groupedAccepts = [];

		if(empty($headerValue))
		{
			return $groupedAccepts;
		}

		// Collect acceptable values

		foreach(explode(',', $headerValue) as $accept)
		{
			$quality = 1;

			if(strpos($accept, ';'))
			{
				// We have a quality so we need to split some more

				[$accept, $quality] = explode(';', $accept, 2);

				// Strip the "q=" part so that we're left with only the numeric value

				$quality = substr(trim($quality), 2);
			}

			$groupedAccepts[$quality][] = trim($accept);
		}

		// Sort in descending order of preference

		krsort($groupedAccepts);

		// Flatten array and return it

		return array_merge(...array_values($groupedAccepts));
	}
protected function parseAcceptHeader ( ? string $ headerValue ) : array { $ groupedAccepts = [ ] ; if ( empty ( $ headerValue ) ) { return $ groupedAccepts ; } // Collect acceptable values foreach ( explode ( ',' , $ headerValue ) as $ accept ) { $ quality = 1 ; if ( strpos ( $ accept , ';' ) ) { // We have a quality so we need to split some more [ $ accept , $ quality ] = explode ( ';' , $ accept , 2 ) ; // Strip the "q=" part so that we're left with only the numeric value $ quality = substr ( trim ( $ quality ) , 2 ) ; } $ groupedAccepts [ $ quality ] [ ] = trim ( $ accept ) ; } // Sort in descending order of preference krsort ( $ groupedAccepts ) ; // Flatten array and return it return array_merge ( ... array_values ( $ groupedAccepts ) ) ; }
Parses a accpet header and returns the values in descending order of preference.

@param  string|null $headerValue Header value
@return array
Parses a accpet header and returns the values in descending order of preference .