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