public static function mediaRangeMatches(string $mediaRange, string $mediaType): bool
    {
        preg_match(self::PATTERN_SPLITMEDIARANGE, $mediaRange, $mediaRangeMatches);
        preg_match(self::PATTERN_SPLITMEDIATYPE, $mediaType, $mediaTypeMatches);
        if ($mediaRangeMatches === [] || $mediaTypeMatches === []) {
            return false;
        }

        $typeMatches = ($mediaRangeMatches['type'] === '*' || $mediaRangeMatches['type'] === $mediaTypeMatches['type']);
        $subtypeMatches = ($mediaRangeMatches['subtype'] === '*' || $mediaRangeMatches['subtype'] === $mediaTypeMatches['subtype']);

        return ($typeMatches && $subtypeMatches);
    }
public static function mediaRangeMatches(string $mediaRange, string $mediaType): bool
    {
        preg_match(self::PATTERN_SPLITMEDIARANGE, $mediaRange, $mediaRangeMatches);
        preg_match(self::PATTERN_SPLITMEDIATYPE, $mediaType, $mediaTypeMatches);
        if ($mediaRangeMatches === [] || $mediaTypeMatches === []) {
            return false;
        }

        $typeMatches = ($mediaRangeMatches['type'] === '*' || $mediaRangeMatches['type'] === $mediaTypeMatches['type']);
        $subtypeMatches = ($mediaRangeMatches['subtype'] === '*' || $mediaRangeMatches['subtype'] === $mediaTypeMatches['subtype']);

        return ($typeMatches && $subtypeMatches);
    }
public static function mediaRangeMatches ( string $ mediaRange , string $ mediaType ) : bool { preg_match ( self :: PATTERN_SPLITMEDIARANGE , $ mediaRange , $ mediaRangeMatches ) ; preg_match ( self :: PATTERN_SPLITMEDIATYPE , $ mediaType , $ mediaTypeMatches ) ; if ( $ mediaRangeMatches === [ ] || $ mediaTypeMatches === [ ] ) { return false ; } $ typeMatches = ( $ mediaRangeMatches [ 'type' ] === '*' || $ mediaRangeMatches [ 'type' ] === $ mediaTypeMatches [ 'type' ] ) ; $ subtypeMatches = ( $ mediaRangeMatches [ 'subtype' ] === '*' || $ mediaRangeMatches [ 'subtype' ] === $ mediaTypeMatches [ 'subtype' ] ) ; return ( $ typeMatches && $ subtypeMatches ) ; }
Checks if the given media range and the media type match.

The pattern used by this function splits each into media type and subtype
and ignores possible additional parameters or extensions. The prepared types
and subtypes are then compared and wildcards are considered in this process.

Media ranges are explained in RFC 2616, section 14.1. "Accept".

@param string $mediaRange The media range, for example "text/*"
@param string $mediaType The media type to match against, for example "text/html"
@return boolean true if both match, false if they don't match or either of them is invalid
Checks if the given media range and the media type match .