Completed
Push — master ( 4e57eb...947d26 )
by J.D.
02:55
created

WordPoints_Hook_Reaction   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 75
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __get() 0 8 2
A get_guid() 0 9 1
A get_reactor_slug() 0 3 1
A get_storage_group_slug() 0 3 1
A get_context_id() 0 3 1
1
<?php
2
3
/**
4
 * Hook reaction class.
5
 *
6
 * @package wordpoints-hooks-api
7
 * @since 1.0.0
8
 */
9
10
/**
11
 * Bootstrap for representing a hook reaction.
12
 *
13
 * @since 1.0.0
14
 */
15
abstract class WordPoints_Hook_Reaction implements WordPoints_Hook_ReactionI {
16
17
	/**
18
	 * @since 1.0.0
19
	 */
20
	protected $ID;
21
22
	/**
23
	 * The reaction storage object.
24
	 *
25
	 * @since 1.0.0
26
	 *
27
	 * @var WordPoints_Hook_Reaction_StorageI
28
	 */
29
	protected $storage;
30
31
	//
32
	// Public Methods.
33
	//
34
35
	/**
36
	 * @since 1.0.0
37
	 */
38
	public function __construct( $id, WordPoints_Hook_Reaction_StorageI $storage ) {
39
40
		$this->ID      = wordpoints_int( $id );
41
		$this->storage = $storage;
42
	}
43
44
	/**
45
	 * @since 1.0.0
46
	 */
47
	public function __get( $var ) {
48
49
		if ( 'ID' === $var ) {
50
			return $this->ID;
51
		}
52
53
		return null;
54
	}
55
56
	/**
57
	 * @since 1.0.0
58
	 */
59
	public function get_guid() {
60
61
		return array(
62
			'id' => $this->ID,
63
			'reactor' => $this->get_reactor_slug(),
64
			'group' => $this->get_storage_group_slug(),
65
			'context_id' => $this->get_context_id(),
66
		);
67
	}
68
69
	/**
70
	 * @since 1.0.0
71
	 */
72
	public function get_reactor_slug() {
73
		return $this->storage->get_reactor_slug();
74
	}
75
76
	/**
77
	 * @since 1.0.0
78
	 */
79
	public function get_storage_group_slug() {
80
		return $this->storage->get_slug();
81
	}
82
83
	/**
84
	 * @since 1.0.0
85
	 */
86
	public function get_context_id() {
87
		return $this->storage->get_context_id();
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->storage->get_context_id(); of type array|false adds the type array to the return on line 87 which is incompatible with the return type declared by the interface WordPoints_Hook_ReactionI::get_context_id of type boolean.
Loading history...
88
	}
89
}
90
91
// EOF
92