Completed
Pull Request — develop (#1233)
by
unknown
02:52
created

Abstract_Sync_Hooks   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A enqueue() 0 7 3
A shutdown() 0 5 2
1
<?php
2
3
namespace Wordlift\Dataset;
4
5
abstract class Abstract_Sync_Hooks {
6
7
	private $queue = array();
8
9
	function __construct() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
10
11
		add_action( 'shutdown', array( $this, 'shutdown' ) );
12
13
	}
14
15
	protected function enqueue( $item ) {
16
17
		if ( empty( $this->queue ) || $item !== $this->queue[ count( $this->queue ) - 1 ] ) {
18
			$this->queue[] = $item;
19
		}
20
21
	}
22
23
	public function shutdown() {
24
		foreach ( $this->queue as $callback ) {
25
			call_user_func( array( $this, $callback[0] ), $callback[1] );
26
		}
27
	}
28
29
}
30