class.jetpack-sync-simple-codec.php 606 B

123456789101112131415161718192021222324
  1. <?php
  2. require_once dirname( __FILE__ ) . '/class.jetpack-sync-json-deflate-array-codec.php';
  3. /**
  4. * An implementation of iJetpack_Sync_Codec that uses gzip's DEFLATE
  5. * algorithm to compress objects serialized using json_encode
  6. */
  7. class Jetpack_Sync_Simple_Codec extends Jetpack_Sync_JSON_Deflate_Array_Codec {
  8. const CODEC_NAME = "simple";
  9. public function name() {
  10. return self::CODEC_NAME;
  11. }
  12. public function encode( $object ) {
  13. return base64_encode( $this->json_serialize( $object ) );
  14. }
  15. public function decode( $input ) {
  16. return $this->json_unserialize( base64_decode( $input ) );
  17. }
  18. }