For media types registered in $_handlers which include an 'encode' setting, encodes data
according to the specified media type.
public static encode ( mixed $handler, mixed $data, object &$response = null ) : mixed | ||
$handler | mixed | Specifies the media type into which `$data` will be encoded. This media type must have an `'encode'` setting specified in `Media::$_handlers`. Alternatively, `$type` can be an array, in which case it is used as the type handler configuration. See the `type()` method for information on adding type handlers, and the available configuration keys. |
$data | mixed | Arbitrary data you wish to encode. Note that some encoders can only handle arrays or objects. |
$response | object | A reference to the `Response` object for this dispatch cycle. |
return | mixed | Returns the result of `$data`, encoded with the encoding configuration specified by `$type`, the result of which is usually a string. |