Completed
Push — add/sso-analytics ( 683a91...e67d7d )
by
unknown
162:06 queued 152:34
created

Jetpack_Sync_Deflate_Codec   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
dl 0
loc 9
rs 10
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A encode() 0 3 1
A decode() 0 3 1
1
<?php
2
3
require_once dirname( __FILE__ ) . '/interface.jetpack-sync-codec.php';
4
5
/**
6
 * An implementation of iJetpack_Sync_Codec that uses gzip's DEFLATE
7
 * algorithm to compress objects serialized using PHP's default
8
 * serializer
9
 */
10
class Jetpack_Sync_Deflate_Codec implements iJetpack_Sync_Codec {
11
	public function encode( $object ) {
12
		return base64_encode( gzdeflate( serialize( $object ) ) );
13
	}
14
15
	public function decode( $input ) {
16
		return unserialize( gzinflate( base64_decode( $input ) ) );
17
	}
18
}