public static function body($message)
    {
        if (!isset($message['body'])) {
            return null;
        }

        if ($message['body'] instanceof StreamInterface) {
            return (string) $message['body'];
        }

        switch (gettype($message['body'])) {
            case 'string':
                return $message['body'];
            case 'resource':
                return stream_get_contents($message['body']);
            case 'object':
                if ($message['body'] instanceof \Iterator) {
                    return implode('', iterator_to_array($message['body']));
                } elseif (method_exists($message['body'], '__toString')) {
                    return (string) $message['body'];
                }
            default:
                throw new \InvalidArgumentException('Invalid request body: '
                    . self::describeType($message['body']));
        }
    }
public static function body($message)
    {
        if (!isset($message['body'])) {
            return null;
        }

        if ($message['body'] instanceof StreamInterface) {
            return (string) $message['body'];
        }

        switch (gettype($message['body'])) {
            case 'string':
                return $message['body'];
            case 'resource':
                return stream_get_contents($message['body']);
            case 'object':
                if ($message['body'] instanceof \Iterator) {
                    return implode('', iterator_to_array($message['body']));
                } elseif (method_exists($message['body'], '__toString')) {
                    return (string) $message['body'];
                }
            default:
                throw new \InvalidArgumentException('Invalid request body: '
                    . self::describeType($message['body']));
        }
    }
public static function body ( $ message ) { if ( ! isset ( $ message [ 'body' ] ) ) { return null ; } if ( $ message [ 'body' ] instanceof StreamInterface ) { return ( string ) $ message [ 'body' ] ; } switch ( gettype ( $ message [ 'body' ] ) ) { case 'string' : return $ message [ 'body' ] ; case 'resource' : return stream_get_contents ( $ message [ 'body' ] ) ; case 'object' : if ( $ message [ 'body' ] instanceof \ Iterator ) { return implode ( '' , iterator_to_array ( $ message [ 'body' ] ) ) ; } elseif ( method_exists ( $ message [ 'body' ] , '__toString' ) ) { return ( string ) $ message [ 'body' ] ; } default : throw new \ InvalidArgumentException ( 'Invalid request body: ' . self :: describeType ( $ message [ 'body' ] ) ) ; } }
Reads the body of a message into a string.

@param array|FutureArrayInterface $message Array containing a "body" key

@return null|string Returns the body as a string or null if not set.
@throws \InvalidArgumentException if a request body is invalid.
Reads the body of a message into a string .