src/Http/Message.php
public function to($format, $options = [])
    {
        $media = $this->_classes['media'];
        if (!$media::get($format)) {
            throw new InvalidArgumentException("Unsupported format `{$format}`.");
        }
        return $media::decode($format, $this->body(), $options, $this);
    }
public function to($format, $options = [])
    {
        $media = $this->_classes['media'];
        if (!$media::get($format)) {
            throw new InvalidArgumentException("Unsupported format `{$format}`.");
        }
        return $media::decode($format, $this->body(), $options, $this);
    }
public function to ( $ format , $ options = [ ] ) { $ media = $ this -> _classes [ 'media' ] ; if ( ! $ media :: get ( $ format ) ) { throw new InvalidArgumentException ( "Unsupported format `{$format}`." ) ; } return $ media :: decode ( $ format , $ this -> body ( ) , $ options , $ this ) ; }
Exports a `Message` body to specific format.

The supported values of `$format` depend on the `Media` class example:

```php
$message->to('xml'); // exports the message body into XML
```

@param  string $format  By default the only supported value is `'array'`. However, additional
format handlers can be registered using the `formats()` method.
@param  array  $options Options for converting the collection.
@return mixed           The converted collection.
Exports a Message body to specific format .