Completed
Push — dna-full-sync-module ( 762324...644e0a )
by
unknown
113:10 queued 100:39
created

Stats   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A init_listeners() 0 4 1
A sync_site_stats() 0 3 1
A init_before_send() 0 3 1
A add_stats() 0 3 1
1
<?php
2
3
namespace Automattic\Jetpack\Sync\Modules;
4
5
class Stats extends \Jetpack_Sync_Module {
6
7
	function name() {
8
		return 'stats';
9
	}
10
11
	function init_listeners( $callback ) {
12
		add_action( 'jetpack_heartbeat', array( $this, 'sync_site_stats' ), 20 );
13
		add_action( 'jetpack_sync_heartbeat_stats', $callback );
14
	}
15
	/*
16
	 * This namespaces the action that we sync.
17
	 * So that we can differentiate it from future actions.
18
	 */
19
	public function sync_site_stats() {
20
		do_action( 'jetpack_sync_heartbeat_stats' );
21
	}
22
23
	public function init_before_send() {
24
		add_filter( 'jetpack_sync_before_send_jetpack_sync_heartbeat_stats', array( $this, 'add_stats' ) );
25
	}
26
27
	public function add_stats() {
28
		return array( \Jetpack::get_stat_data( false, false ) );
29
	}
30
}
31