Completed
Push — branch-7.5 ( 9378b5...5f3718 )
by Jeremy
211:39 queued 203:47
created

Simple_Codec::name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Automattic\Jetpack\Sync;
4
5
/**
6
 * An implementation of Automattic\Jetpack\Sync\Codec_Interface that uses gzip's DEFLATE
7
 * algorithm to compress objects serialized using json_encode
8
 */
9
class Simple_Codec extends 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