Completed
Push — fix/inline-docs-410 ( f96891...63b75c )
by
unknown
43:24 queued 33:40
created

Jetpack_Sync_Module   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 8
lcom 0
cbo 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
name() 0 1 ?
A init_listeners() 0 1 1
A init_before_send() 0 1 1
A set_defaults() 0 1 1
A reset_data() 0 1 1
A get_check_sum() 0 3 1
A still_valid_checksum() 0 6 3
1
<?php
2
3
/**
4
 * Basic methods implemented by Jetpack Sync extensions
5
 */
6
7
abstract class Jetpack_Sync_Module {
8
	abstract public function name();
9
10
	// override these to set up listeners and set/reset data/defaults
11
	public function init_listeners( $callable ) {}
12
	public function init_before_send() {}
13
	public function set_defaults() {}
14
	public function reset_data() {}
15
16
	protected function get_check_sum( $values ) {
17
		return crc32( json_encode( $values ) );
18
	}
19
20
	protected function still_valid_checksum( $sums_to_check, $name, $new_sum ) {
21
		if ( isset( $sums_to_check[ $name ] ) && $sums_to_check[ $name ] === $new_sum ) {
22
			return true;
23
		}
24
		return false;
25
	}
26
}