public function serialize($serializablePage, $format)
    {
        // check if supported serialization format
        if (!SerpPageSerializerHelper::validFormat($format, self::$supportedFormatSerialization))
            throw new \Franzip\SerpPageSerializer\Exceptions\UnsupportedSerializationFormatException('Invalid SerpPageSerializer $format: supported serialization formats are JSON, XML and YAML.');
        // typecheck the object to serialize
        if (!SerpPageSerializerHelper::serializablePage($serializablePage))
            throw new \Franzip\SerpPageSerializer\Exceptions\NonSerializableObjectException('Invalid SerpPageSerializer $serializablePage: you must supply a SerializableSerpPage object to serialize.');

        $format           = strtolower($format);
        $entries          = $this->createEntries($serializablePage, $format);
        $serializablePage = $this->prepareForSerialization($serializablePage, $format, $entries);
        $serializedPage   = $this->getSerializer()->serialize($serializablePage, $format);
        // beautify output if JSON
        $content          = ($format == 'json') ? SerpPageSerializerHelper::prettyJSON($serializedPage) : $serializedPage;
        return new SerializedSerpPage($content);
    }
public function serialize($serializablePage, $format)
    {
        // check if supported serialization format
        if (!SerpPageSerializerHelper::validFormat($format, self::$supportedFormatSerialization))
            throw new \Franzip\SerpPageSerializer\Exceptions\UnsupportedSerializationFormatException('Invalid SerpPageSerializer $format: supported serialization formats are JSON, XML and YAML.');
        // typecheck the object to serialize
        if (!SerpPageSerializerHelper::serializablePage($serializablePage))
            throw new \Franzip\SerpPageSerializer\Exceptions\NonSerializableObjectException('Invalid SerpPageSerializer $serializablePage: you must supply a SerializableSerpPage object to serialize.');

        $format           = strtolower($format);
        $entries          = $this->createEntries($serializablePage, $format);
        $serializablePage = $this->prepareForSerialization($serializablePage, $format, $entries);
        $serializedPage   = $this->getSerializer()->serialize($serializablePage, $format);
        // beautify output if JSON
        $content          = ($format == 'json') ? SerpPageSerializerHelper::prettyJSON($serializedPage) : $serializedPage;
        return new SerializedSerpPage($content);
    }
public function serialize ( $ serializablePage , $ format ) { // check if supported serialization format if ( ! SerpPageSerializerHelper :: validFormat ( $ format , self :: $ supportedFormatSerialization ) ) throw new \ Franzip \ SerpPageSerializer \ Exceptions \ UnsupportedSerializationFormatException ( 'Invalid SerpPageSerializer $format: supported serialization formats are JSON, XML and YAML.' ) ; // typecheck the object to serialize if ( ! SerpPageSerializerHelper :: serializablePage ( $ serializablePage ) ) throw new \ Franzip \ SerpPageSerializer \ Exceptions \ NonSerializableObjectException ( 'Invalid SerpPageSerializer $serializablePage: you must supply a SerializableSerpPage object to serialize.' ) ; $ format = strtolower ( $ format ) ; $ entries = $ this -> createEntries ( $ serializablePage , $ format ) ; $ serializablePage = $ this -> prepareForSerialization ( $ serializablePage , $ format , $ entries ) ; $ serializedPage = $ this -> getSerializer ( ) -> serialize ( $ serializablePage , $ format ) ; // beautify output if JSON $ content = ( $ format == 'json' ) ? SerpPageSerializerHelper :: prettyJSON ( $ serializedPage ) : $ serializedPage ; return new SerializedSerpPage ( $ content ) ; }
Serialize a SerializableSerpPage object in the target format
@param  SerializableSerpPage $serializablePage
@param  string               $format
@return string
Serialize a SerializableSerpPage object in the target format