/** * Serialize a PHP value to AMF0 format * * @param mixed $value * @param array $opts * @return string * @throws \Zend\Serializer\Exception */ public function serialize($value, array $opts = array()) { try { $stream = new AMFParser\OutputStream(); $serializer = new AMFParser\AMF0\Serializer($stream); $serializer->writeTypeMarker($value); return $stream->getStream(); } catch (\Exception $e) { throw new SerializationException('Serialization failed by previous error', 0, $e); } }
/** * Serialize a PHP value to AMF3 format * * @param mixed $value * @param array $opts * @return string * @throws Zend\Serializer\Exception */ public function serialize($value, array $opts = array()) { try { $stream = new AmfParser\OutputStream(); $serializer = new AmfParser\Amf3\Serializer($stream); $serializer->writeTypeMarker($value); return $stream->getStream(); } catch (\Exception $e) { throw new RuntimeException('Serialization failed: ' . $e->getMessage(), 0, $e); } }
/** * Return the output stream content * * @return string The contents of the output stream */ public function getResponse() { return $this->_outputStream->getStream(); }