public static function parseAccept(string $accept)
    {
        $result = [];

        foreach (explode(',', $accept) as $directive) {
            $parts = explode(';', $directive, 2);

            $type = trim($parts[0]);

            $priority = ((float) filter_var(
                $parts[1] ?? 1,
                FILTER_SANITIZE_NUMBER_FLOAT,
                FILTER_FLAG_ALLOW_FRACTION
            ));
            $priority = Utils::numberLimit($priority, 0, 1);

            if (strpos($type, '*') !== false) {
                $priority -= 0.0001;
            }
            $result[$type] = $priority;
        }

        return $result;
    }
public static function parseAccept(string $accept)
    {
        $result = [];

        foreach (explode(',', $accept) as $directive) {
            $parts = explode(';', $directive, 2);

            $type = trim($parts[0]);

            $priority = ((float) filter_var(
                $parts[1] ?? 1,
                FILTER_SANITIZE_NUMBER_FLOAT,
                FILTER_FLAG_ALLOW_FRACTION
            ));
            $priority = Utils::numberLimit($priority, 0, 1);

            if (strpos($type, '*') !== false) {
                $priority -= 0.0001;
            }
            $result[$type] = $priority;
        }

        return $result;
    }
public static function parseAccept ( string $ accept ) { $ result = [ ] ; foreach ( explode ( ',' , $ accept ) as $ directive ) { $ parts = explode ( ';' , $ directive , 2 ) ; $ type = trim ( $ parts [ 0 ] ) ; $ priority = ( ( float ) filter_var ( $ parts [ 1 ] ?? 1 , FILTER_SANITIZE_NUMBER_FLOAT , FILTER_FLAG_ALLOW_FRACTION ) ) ; $ priority = Utils :: numberLimit ( $ priority , 0 , 1 ) ; if ( strpos ( $ type , '*' ) !== false ) { $ priority -= 0.0001 ; } $ result [ $ type ] = $ priority ; } return $ result ; }
Parses Accept header

@param string $accept Accept header

@return float[] With 'type' => priority
Keys may contain '*'
Parses Accept header