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

Abstract_Sync_Hooks::shutdown()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
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