public static function suitable($message, $mime = null)
    {
        $formats = static::$_formats;

        if (func_num_args() === 1) {
            $mime = $message->mime();
        }

        foreach ($formats as $format => $definition) {
            if (!in_array($mime, $definition['mime'], true)) {
                continue;
            }

            if ($message instanceof Cgi\Request) {
                foreach ($definition['conditions'] as $key => $value) {
                    switch (true) {
                        case strpos($key, ':'):
                            if ($message->attr($key) !== $value) {
                                continue 2;
                            }
                        break;
                        case ($message->is($key) !== $value):
                            continue 2;
                        break;
                    }
                }
            }
            return $format;
        }
    }
public static function suitable($message, $mime = null)
    {
        $formats = static::$_formats;

        if (func_num_args() === 1) {
            $mime = $message->mime();
        }

        foreach ($formats as $format => $definition) {
            if (!in_array($mime, $definition['mime'], true)) {
                continue;
            }

            if ($message instanceof Cgi\Request) {
                foreach ($definition['conditions'] as $key => $value) {
                    switch (true) {
                        case strpos($key, ':'):
                            if ($message->attr($key) !== $value) {
                                continue 2;
                            }
                        break;
                        case ($message->is($key) !== $value):
                            continue 2;
                        break;
                    }
                }
            }
            return $format;
        }
    }
public static function suitable ( $ message , $ mime = null ) { $ formats = static :: $ _formats ; if ( func_num_args ( ) === 1 ) { $ mime = $ message -> mime ( ) ; } foreach ( $ formats as $ format => $ definition ) { if ( ! in_array ( $ mime , $ definition [ 'mime' ] , true ) ) { continue ; } if ( $ message instanceof Cgi \ Request ) { foreach ( $ definition [ 'conditions' ] as $ key => $ value ) { switch ( true ) { case strpos ( $ key , ':' ) : if ( $ message -> attr ( $ key ) !== $ value ) { continue 2 ; } break ; case ( $ message -> is ( $ key ) !== $ value ) : continue 2 ; break ; } } } return $ format ; } }
Iterates through all existing formats to match a compatible one for the provided request.

@param  object  $message An instance of message.
@param  string  $mime    An overriding content type.
@return boolean          Returns a compatible format name or `null` if none matched.
Iterates through all existing formats to match a compatible one for the provided request .