src/Phapi/Middleware/ContentNegotiation/FormatNegotiation.php
private function parseParts(array $parts = [])
    {
        // Get and unset the mime type
        $mimeType = $parts[0];
        unset($parts[0]);

        // Set default quality to 1 since the HTTP/1.1 specification says that if no
        // quality is provided it defaults to 1
        $support = [ 'value' => $mimeType, 'quality' => (float) 1 ];

        // Loop through the parts
        foreach ($parts as $part) {
            // Save all params
            $param = explode('=', $part);
            // Make sure we exploded the string
            if (isset($param[1])) {
                // Save param
                if ($param[0] === 'q') {
                    $support['quality'] = (float) $param[1];
                } else {
                    $support['parameters'][$param[0]] = $param[1];
                }
            }
        }

        return $support;
    }
private function parseParts(array $parts = [])
    {
        // Get and unset the mime type
        $mimeType = $parts[0];
        unset($parts[0]);

        // Set default quality to 1 since the HTTP/1.1 specification says that if no
        // quality is provided it defaults to 1
        $support = [ 'value' => $mimeType, 'quality' => (float) 1 ];

        // Loop through the parts
        foreach ($parts as $part) {
            // Save all params
            $param = explode('=', $part);
            // Make sure we exploded the string
            if (isset($param[1])) {
                // Save param
                if ($param[0] === 'q') {
                    $support['quality'] = (float) $param[1];
                } else {
                    $support['parameters'][$param[0]] = $param[1];
                }
            }
        }

        return $support;
    }
private function parseParts ( array $ parts = [ ] ) { // Get and unset the mime type $ mimeType = $ parts [ 0 ] ; unset ( $ parts [ 0 ] ) ; // Set default quality to 1 since the HTTP/1.1 specification says that if no // quality is provided it defaults to 1 $ support = [ 'value' => $ mimeType , 'quality' => ( float ) 1 ] ; // Loop through the parts foreach ( $ parts as $ part ) { // Save all params $ param = explode ( '=' , $ part ) ; // Make sure we exploded the string if ( isset ( $ param [ 1 ] ) ) { // Save param if ( $ param [ 0 ] === 'q' ) { $ support [ 'quality' ] = ( float ) $ param [ 1 ] ; } else { $ support [ 'parameters' ] [ $ param [ 0 ] ] = $ param [ 1 ] ; } } } return $ support ; }
Parse the different parts of the media range

@param array $parts
@return array
Parse the different parts of the media range