Completed
Push — master ( 711d1c...aa04da )
by J.D.
11:00 queued 11:00
created
src/includes/classes/hook/events.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @since 1.0.0
39 39
 	 */
40
-	public function __construct( $slug ) {
40
+	public function __construct($slug) {
41 41
 
42 42
 		$hooks = wordpoints_hooks();
43 43
 
44 44
 		$this->router = $hooks->router;
45 45
 
46
-		parent::__construct( $slug );
46
+		parent::__construct($slug);
47 47
 	}
48 48
 
49 49
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function init() {
53 53
 
54
-		$this->sub_apps->register( 'args', 'WordPoints_Class_Registry_Children' );
54
+		$this->sub_apps->register('args', 'WordPoints_Class_Registry_Children');
55 55
 
56 56
 		parent::init();
57 57
 	}
@@ -75,29 +75,29 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return bool Whether the event was registered.
77 77
 	 */
78
-	public function register( $slug, $class, array $args = array() ) {
78
+	public function register($slug, $class, array $args = array()) {
79 79
 
80 80
 		// TODO shoudl this be required?
81
-		if ( ! isset( $args['actions'] ) ) {
81
+		if ( ! isset($args['actions'])) {
82 82
 			return false;
83 83
 		}
84 84
 
85
-		parent::register( $slug, $class, $args );
85
+		parent::register($slug, $class, $args);
86 86
 
87
-		foreach ( $args['actions'] as $type => $actions ) {
88
-			foreach ( (array) $actions as $action_slug ) {
89
-				$this->router->add_event_to_action( $slug, $action_slug, $type );
87
+		foreach ($args['actions'] as $type => $actions) {
88
+			foreach ((array) $actions as $action_slug) {
89
+				$this->router->add_event_to_action($slug, $action_slug, $type);
90 90
 			}
91 91
 		}
92 92
 
93 93
 		// TODO should this be required?
94
-		if ( isset( $args['args'] ) ) {
95
-			foreach ( $args['args'] as $arg_slug => $class ) {
96
-				$this->args->register( $slug, $arg_slug, $class );
94
+		if (isset($args['args'])) {
95
+			foreach ($args['args'] as $arg_slug => $class) {
96
+				$this->args->register($slug, $arg_slug, $class);
97 97
 			}
98 98
 		}
99 99
 
100
-		$this->event_data[ $slug ] = $args;
100
+		$this->event_data[$slug] = $args;
101 101
 
102 102
 		return true;
103 103
 	}
@@ -105,23 +105,23 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 * @since 1.0.0
107 107
 	 */
108
-	public function deregister( $slug ) {
108
+	public function deregister($slug) {
109 109
 
110
-		if ( ! $this->is_registered( $slug ) ) {
110
+		if ( ! $this->is_registered($slug)) {
111 111
 			return;
112 112
 		}
113 113
 
114
-		parent::deregister( $slug );
114
+		parent::deregister($slug);
115 115
 
116
-		foreach ( (array) $this->event_data[ $slug ]['actions'] as $type => $actions ) {
117
-			foreach ( (array) $actions as $action_slug ) {
118
-				$this->router->remove_event_from_action( $slug, $action_slug, $type );
116
+		foreach ((array) $this->event_data[$slug]['actions'] as $type => $actions) {
117
+			foreach ((array) $actions as $action_slug) {
118
+				$this->router->remove_event_from_action($slug, $action_slug, $type);
119 119
 			}
120 120
 		}
121 121
 
122
-		$this->args->deregister_children( $slug );
122
+		$this->args->deregister_children($slug);
123 123
 
124
-		unset( $this->event_data[ $slug ] );
124
+		unset($this->event_data[$slug]);
125 125
 	}
126 126
 }
127 127
 
Please login to merge, or discard this patch.
src/includes/classes/hook/extension.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
 		WordPoints_Hook_Event_Args $event_args
66 66
 	) {
67 67
 
68
-		if ( ! isset( $settings[ $this->slug ] ) ) {
68
+		if ( ! isset($settings[$this->slug])) {
69 69
 			return $settings;
70 70
 		}
71 71
 
72 72
 		$this->validator = $validator;
73 73
 		$this->event_args = $event_args;
74 74
 
75
-		$this->validator->push_field( $this->slug );
76
-		$settings[ $this->slug ] = $this->{"validate_{$this->slug}"}( $settings[ $this->slug ] );
75
+		$this->validator->push_field($this->slug);
76
+		$settings[$this->slug] = $this->{"validate_{$this->slug}"}($settings[$this->slug]);
77 77
 		$this->validator->pop_field();
78 78
 
79 79
 		return $settings;
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 	/**
83 83
 	 * @since 1.0.0
84 84
 	 */
85
-	public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) {
85
+	public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) {
86 86
 
87
-		if ( isset( $settings[ $this->slug ] ) ) {
88
-			$reaction->update_meta( $this->slug, $settings[ $this->slug ] );
87
+		if (isset($settings[$this->slug])) {
88
+			$reaction->update_meta($this->slug, $settings[$this->slug]);
89 89
 		} else {
90
-			$reaction->delete_meta( $this->slug );
90
+			$reaction->delete_meta($this->slug);
91 91
 		}
92 92
 	}
93 93
 
Please login to merge, or discard this patch.
src/includes/classes/hook/extension/conditions.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
 
43 43
 		$conditions_data = array();
44 44
 
45
-		foreach ( $this->conditions->get_all() as $data_type => $conditions ) {
46
-			foreach ( $conditions as $slug => $condition ) {
45
+		foreach ($this->conditions->get_all() as $data_type => $conditions) {
46
+			foreach ($conditions as $slug => $condition) {
47 47
 
48
-				if ( ! ( $condition instanceof WordPoints_Hook_Condition ) ) {
48
+				if ( ! ($condition instanceof WordPoints_Hook_Condition)) {
49 49
 					continue;
50 50
 				}
51 51
 
52
-				$conditions_data[ $data_type ][ $slug ] = array(
52
+				$conditions_data[$data_type][$slug] = array(
53 53
 					'slug'      => $slug,
54 54
 					'data_type' => $data_type,
55 55
 					'title'     => $condition->get_title(),
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 			}
59 59
 		}
60 60
 
61
-		return array( 'conditions' => $conditions_data );
61
+		return array('conditions' => $conditions_data);
62 62
 	}
63 63
 
64 64
 	/**
@@ -70,31 +70,31 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return array The validated settings.
72 72
 	 */
73
-	protected function validate_conditions( $args ) {
73
+	protected function validate_conditions($args) {
74 74
 
75
-		if ( ! is_array( $args ) ) {
75
+		if ( ! is_array($args)) {
76 76
 
77 77
 			$this->validator->add_error(
78
-				__( 'Conditions do not match expected format.', 'wordpoints' )
78
+				__('Conditions do not match expected format.', 'wordpoints')
79 79
 			);
80 80
 
81 81
 			return array();
82 82
 		}
83 83
 
84
-		foreach ( $args as $arg_slug => $sub_args ) {
84
+		foreach ($args as $arg_slug => $sub_args) {
85 85
 
86
-			if ( '_conditions' === $arg_slug ) {
86
+			if ('_conditions' === $arg_slug) {
87 87
 
88
-				$this->validator->push_field( $arg_slug );
88
+				$this->validator->push_field($arg_slug);
89 89
 
90
-				foreach ( $sub_args as $index => $settings ) {
90
+				foreach ($sub_args as $index => $settings) {
91 91
 
92
-					$this->validator->push_field( $index );
92
+					$this->validator->push_field($index);
93 93
 
94
-					$condition = $this->validate_condition( $settings );
94
+					$condition = $this->validate_condition($settings);
95 95
 
96
-					if ( $condition ) {
97
-						$sub_args[ $index ] = $condition;
96
+					if ($condition) {
97
+						$sub_args[$index] = $condition;
98 98
 					}
99 99
 
100 100
 					$this->validator->pop_field();
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
 
105 105
 			} else {
106 106
 
107
-				if ( ! $this->event_args->descend( $arg_slug ) ) {
107
+				if ( ! $this->event_args->descend($arg_slug)) {
108 108
 					continue;
109 109
 				}
110 110
 
111
-				$sub_args = $this->validate_conditions( $sub_args );
111
+				$sub_args = $this->validate_conditions($sub_args);
112 112
 
113
-				$args[ $arg_slug ] = $sub_args;
113
+				$args[$arg_slug] = $sub_args;
114 114
 
115 115
 				$this->event_args->ascend();
116 116
 			}
117 117
 
118
-			$args[ $arg_slug ] = $sub_args;
118
+			$args[$arg_slug] = $sub_args;
119 119
 		}
120 120
 
121 121
 		return $args;
@@ -131,32 +131,32 @@  discard block
 block discarded – undo
131 131
 	 * @return array|false The validated conditions settings, or false if unable to
132 132
 	 *                     validate.
133 133
 	 */
134
-	protected function validate_condition( $settings ) {
134
+	protected function validate_condition($settings) {
135 135
 
136
-		if ( ! isset( $settings['type'] ) ) {
137
-			$this->validator->add_error( __( 'Condition type is missing.', 'wordpoints' ) );
136
+		if ( ! isset($settings['type'])) {
137
+			$this->validator->add_error(__('Condition type is missing.', 'wordpoints'));
138 138
 			return false;
139 139
 		}
140 140
 
141 141
 		$arg = $this->event_args->get_current();
142 142
 
143
-		$data_type = $this->get_data_type( $arg );
143
+		$data_type = $this->get_data_type($arg);
144 144
 
145
-		if ( ! $data_type ) {
145
+		if ( ! $data_type) {
146 146
 			$this->validator->add_error(
147
-				__( 'This type of condition does not work for the selected attribute.', 'wordpoints' )
147
+				__('This type of condition does not work for the selected attribute.', 'wordpoints')
148 148
 			);
149 149
 
150 150
 			return false;
151 151
 		}
152 152
 
153
-		$condition = wordpoints_hooks()->conditions->get( $data_type, $settings['type'] );
153
+		$condition = wordpoints_hooks()->conditions->get($data_type, $settings['type']);
154 154
 
155
-		if ( ! $condition ) {
155
+		if ( ! $condition) {
156 156
 
157 157
 			$this->validator->add_error(
158 158
 				sprintf(
159
-					__( 'Unknown condition type “%s”.', 'wordpoints' )
159
+					__('Unknown condition type “%s”.', 'wordpoints')
160 160
 					, $settings['type']
161 161
 				)
162 162
 				, 'type'
@@ -165,12 +165,12 @@  discard block
 block discarded – undo
165 165
 			return false;
166 166
 		}
167 167
 
168
-		if ( ! isset( $settings['settings'] ) ) {
169
-			$this->validator->add_error( __( 'Condition settings are missing.', 'wordpoints' ) );
168
+		if ( ! isset($settings['settings'])) {
169
+			$this->validator->add_error(__('Condition settings are missing.', 'wordpoints'));
170 170
 			return false;
171 171
 		}
172 172
 
173
-		$this->validator->push_field( 'settings' );
173
+		$this->validator->push_field('settings');
174 174
 
175 175
 		$settings['settings'] = $condition->validate_settings(
176 176
 			$arg
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 		WordPoints_Hook_Event_Args $event_args
192 192
 	) {
193 193
 
194
-		$conditions = $reaction->get_meta( 'conditions' );
194
+		$conditions = $reaction->get_meta('conditions');
195 195
 
196
-		if ( $conditions && ! $this->conditions_are_met( $conditions, $event_args ) ) {
196
+		if ($conditions && ! $this->conditions_are_met($conditions, $event_args)) {
197 197
 			return false;
198 198
 		}
199 199
 
@@ -215,35 +215,35 @@  discard block
 block discarded – undo
215 215
 		WordPoints_Hook_Event_Args $event_args
216 216
 	) {
217 217
 
218
-		foreach ( $conditions as $arg_slug => $sub_args ) {
218
+		foreach ($conditions as $arg_slug => $sub_args) {
219 219
 
220
-			$event_args->descend( $arg_slug );
220
+			$event_args->descend($arg_slug);
221 221
 
222
-			if ( isset( $sub_args['_conditions'] ) ) {
222
+			if (isset($sub_args['_conditions'])) {
223 223
 
224
-				foreach ( $sub_args['_conditions'] as $settings ) {
224
+				foreach ($sub_args['_conditions'] as $settings) {
225 225
 
226 226
 					$condition = $this->conditions->get(
227
-						$this->get_data_type( $event_args->get_current() )
227
+						$this->get_data_type($event_args->get_current())
228 228
 						, $settings['type']
229 229
 					);
230 230
 
231
-					$is_met = $condition->is_met( $settings['settings'], $event_args );
231
+					$is_met = $condition->is_met($settings['settings'], $event_args);
232 232
 
233
-					if ( ! $is_met ) {
233
+					if ( ! $is_met) {
234 234
 						$event_args->ascend();
235 235
 						return false;
236 236
 					}
237 237
 				}
238 238
 
239
-				unset( $sub_args['_conditions'] );
239
+				unset($sub_args['_conditions']);
240 240
 			}
241 241
 
242
-			$are_met = $this->conditions_are_met( $sub_args, $event_args );
242
+			$are_met = $this->conditions_are_met($sub_args, $event_args);
243 243
 
244 244
 			$event_args->ascend();
245 245
 
246
-			if ( ! $are_met ) {
246
+			if ( ! $are_met) {
247 247
 				return false;
248 248
 			}
249 249
 		}
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 	 *
261 261
 	 * @return string|false The data type, or false.
262 262
 	 */
263
-	protected function get_data_type( $arg ) {
263
+	protected function get_data_type($arg) {
264 264
 
265
-		if ( $arg instanceof WordPoints_Entity_Attr ) {
265
+		if ($arg instanceof WordPoints_Entity_Attr) {
266 266
 			$data_type = $arg->get_data_type();
267
-		} elseif ( $arg instanceof WordPoints_Entity_Array ) {
267
+		} elseif ($arg instanceof WordPoints_Entity_Array) {
268 268
 			$data_type = 'entity_array';
269
-		} elseif ( $arg instanceof WordPoints_Entity ) {
269
+		} elseif ($arg instanceof WordPoints_Entity) {
270 270
 			$data_type = 'entity';
271 271
 		} else {
272 272
 			$data_type = false;
Please login to merge, or discard this patch.
src/includes/classes/hook/extension/periods.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -28,27 +28,27 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @return array The validated periods.
30 30
 	 */
31
-	protected function validate_periods( $periods ) {
31
+	protected function validate_periods($periods) {
32 32
 
33
-		if ( ! is_array( $periods ) ) {
33
+		if ( ! is_array($periods)) {
34 34
 
35 35
 			$this->validator->add_error(
36
-				__( 'Periods do not match expected format.', 'wordpoints' )
36
+				__('Periods do not match expected format.', 'wordpoints')
37 37
 			);
38 38
 
39 39
 			return array();
40 40
 		}
41 41
 
42
-		foreach ( $periods as $index => $period ) {
42
+		foreach ($periods as $index => $period) {
43 43
 
44
-			$this->validator->push_field( $index );
44
+			$this->validator->push_field($index);
45 45
 
46
-			$period = $this->validate_period( $period );
46
+			$period = $this->validate_period($period);
47 47
 
48
-			if ( $period ) {
49
-				$periods[ $index ] = $period;
48
+			if ($period) {
49
+				$periods[$index] = $period;
50 50
 			} else {
51
-				unset( $periods[ $index ] );
51
+				unset($periods[$index]);
52 52
 			}
53 53
 
54 54
 			$this->validator->pop_field();
@@ -66,56 +66,56 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @return array|false The validated period, or false if invalid.
68 68
 	 */
69
-	protected function validate_period( $period ) {
69
+	protected function validate_period($period) {
70 70
 
71
-		if ( ! is_array( $period ) ) {
71
+		if ( ! is_array($period)) {
72 72
 			$this->validator->add_error(
73
-				__( 'Period does not match expected format.', 'wordpoints' )
73
+				__('Period does not match expected format.', 'wordpoints')
74 74
 			);
75 75
 
76 76
 			return false;
77 77
 		}
78 78
 
79
-		if ( ! isset( $period['args'] ) ) {
79
+		if ( ! isset($period['args'])) {
80 80
 			// TODO is there a default period args?
81 81
 			$period['args'] = array();
82 82
 		}
83 83
 
84
-		if ( ! is_array( $period['args'] ) ) {
84
+		if ( ! is_array($period['args'])) {
85 85
 			return false;
86 86
 		}
87 87
 
88
-		if ( ! $this->event_args->get_from_hierarchy( $period['args'] ) ) {
88
+		if ( ! $this->event_args->get_from_hierarchy($period['args'])) {
89 89
 			$this->validator->add_error(
90
-				__( 'Invalid period.', 'wordpoints' ) // TODO better error message
90
+				__('Invalid period.', 'wordpoints') // TODO better error message
91 91
 				, 'args'
92 92
 			);
93 93
 
94 94
 			return false;
95 95
 		}
96 96
 
97
-		if ( ! isset( $period['settings'] ) ) {
97
+		if ( ! isset($period['settings'])) {
98 98
 			$this->validator->add_error(
99
-				__( 'Period settings are missing.', 'wordpoints' )
99
+				__('Period settings are missing.', 'wordpoints')
100 100
 			);
101 101
 
102 102
 			return false;
103 103
 		}
104 104
 
105
-		if ( ! isset( $period['settings']['length'] ) ) {
105
+		if ( ! isset($period['settings']['length'])) {
106 106
 			$this->validator->add_error(
107
-				__( 'Period length setting is missing.', 'wordpoints' )
107
+				__('Period length setting is missing.', 'wordpoints')
108 108
 				, 'settings'
109 109
 			);
110 110
 
111 111
 			return false;
112 112
 		}
113 113
 
114
-		$this->validator->push_field( 'settings' );
114
+		$this->validator->push_field('settings');
115 115
 
116
-		if ( false === wordpoints_posint( $period['settings']['length'] ) ) {
116
+		if (false === wordpoints_posint($period['settings']['length'])) {
117 117
 			$this->validator->add_error(
118
-				__( 'Period length must be a positive integer.', 'wordpoints' )
118
+				__('Period length must be a positive integer.', 'wordpoints')
119 119
 				, 'length'
120 120
 			);
121 121
 
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 	/**
131 131
 	 * @since 1.0.0
132 132
 	 */
133
-	public function should_hit( WordPoints_Hook_Reaction_Validator $reaction, WordPoints_Hook_Event_Args $event_args ) {
133
+	public function should_hit(WordPoints_Hook_Reaction_Validator $reaction, WordPoints_Hook_Event_Args $event_args) {
134 134
 
135
-		$periods = $reaction->get_meta( 'periods' );
135
+		$periods = $reaction->get_meta('periods');
136 136
 
137
-		if ( empty( $periods ) ) {
137
+		if (empty($periods)) {
138 138
 			return true;
139 139
 		}
140 140
 
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 
143 143
 		$this->event_args = $event_args;
144 144
 
145
-		foreach ( $periods as $period ) {
146
-			if ( ! $this->has_period_ended( $period, $reaction_id ) ) {
145
+		foreach ($periods as $period) {
146
+			if ( ! $this->has_period_ended($period, $reaction_id)) {
147 147
 				return false;
148 148
 			}
149 149
 		}
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @return bool Whether the period has ended.
165 165
 	 */
166
-	final private function has_period_ended( array $settings, $reaction_id ) {
166
+	final private function has_period_ended(array $settings, $reaction_id) {
167 167
 
168 168
 		$period = $this->get_period_by_reaction(
169
-			$this->get_arg_values( $settings['args'] )
169
+			$this->get_arg_values($settings['args'])
170 170
 			, $reaction_id
171 171
 		);
172 172
 
173 173
 		// If the period isn't found, we know that we can still fire.
174
-		if ( ! $period ) {
174
+		if ( ! $period) {
175 175
 			return true;
176 176
 		}
177 177
 
178
-		if ( ! empty( $settings['settings']['absolute'] ) ) {
179
-			return ( $period->expiration < current_time( 'timestamp' ) );
178
+		if ( ! empty($settings['settings']['absolute'])) {
179
+			return ($period->expiration < current_time('timestamp'));
180 180
 		} else {
181 181
 			return false;
182 182
 		}
@@ -191,18 +191,18 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @return array The arg values.
193 193
 	 */
194
-	final private function get_arg_values( array $period_args ) {
194
+	final private function get_arg_values(array $period_args) {
195 195
 
196 196
 		$values = array();
197 197
 
198
-		foreach ( $period_args as $arg_slug => $sub_args ) {
198
+		foreach ($period_args as $arg_slug => $sub_args) {
199 199
 
200
-			$this->event_args->descend( $arg_slug );
200
+			$this->event_args->descend($arg_slug);
201 201
 
202
-			if ( is_array( $sub_args ) ) {
203
-				$values = array_merge( $values, $this->get_arg_values( $sub_args ) );
202
+			if (is_array($sub_args)) {
203
+				$values = array_merge($values, $this->get_arg_values($sub_args));
204 204
 			} else {
205
-				$values[ $arg_slug ] = $this->event_args->get_current()->get_the_value();
205
+				$values[$arg_slug] = $this->event_args->get_current()->get_the_value();
206 206
 			}
207 207
 
208 208
 			$this->event_args->ascend();
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return object|false The period data, or false if not found.
222 222
 	 */
223
-	final private function get_period( $period_id ) {
223
+	final private function get_period($period_id) {
224 224
 
225
-		$period = wp_cache_get( $period_id, 'wordpoints_hook_period' );
225
+		$period = wp_cache_get($period_id, 'wordpoints_hook_period');
226 226
 
227
-		if ( ! $period ) {
227
+		if ( ! $period) {
228 228
 
229 229
 			global $wpdb;
230 230
 
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
 				)
240 240
 			);
241 241
 
242
-			if ( ! $period ) {
242
+			if ( ! $period) {
243 243
 				return false;
244 244
 			}
245 245
 
246
-			wp_cache_set( $period->hook_id . $period->arg_hash, $period->id, 'wordpoints_hook_period_ids' );
247
-			wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
246
+			wp_cache_set($period->hook_id.$period->arg_hash, $period->id, 'wordpoints_hook_period_ids');
247
+			wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
248 248
 		}
249 249
 
250 250
 		return $period;
@@ -260,19 +260,19 @@  discard block
 block discarded – undo
260 260
 	 *
261 261
 	 * @return object|false The period data, or false if not found.
262 262
 	 */
263
-	final private function get_period_by_reaction( array $args, $reaction_id ) {
263
+	final private function get_period_by_reaction(array $args, $reaction_id) {
264 264
 
265 265
 		// The periods for a reaction are differentiated by a hash of specific args.
266
-		$arg_hash = md5( serialize( $args ) );
266
+		$arg_hash = md5(serialize($args));
267 267
 
268 268
 		$cache_key = "{$this->slug}-{$reaction_id}-{$arg_hash}";
269 269
 
270 270
 		// Before we run the query, we try to lookup the ID in the cache.
271
-		$period_id = wp_cache_get( $cache_key, 'wordpoints_hook_period_ids' );
271
+		$period_id = wp_cache_get($cache_key, 'wordpoints_hook_period_ids');
272 272
 
273 273
 		// If we found it, we can retrieve the period by ID instead.
274
-		if ( $period_id ) {
275
-			return $this->get_period( $period_id );
274
+		if ($period_id) {
275
+			return $this->get_period($period_id);
276 276
 		}
277 277
 
278 278
 		global $wpdb;
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 			)
292 292
 		);
293 293
 
294
-		if ( ! $period ) {
294
+		if ( ! $period) {
295 295
 			return false;
296 296
 		}
297 297
 
298
-		wp_cache_set( $cache_key, $period->id, 'wordpoints_hook_period_ids' );
299
-		wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
298
+		wp_cache_set($cache_key, $period->id, 'wordpoints_hook_period_ids');
299
+		wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
300 300
 
301 301
 		return $period;
302 302
 	}
Please login to merge, or discard this patch.
src/includes/classes/hook/firer.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
 	 * @since 1.0.0
19 19
 	 */
20
-	public function do_event( $event_slug, WordPoints_Hook_Event_Args $event_args ) {
20
+	public function do_event($event_slug, WordPoints_Hook_Event_Args $event_args) {
21 21
 
22 22
 		$hooks = wordpoints_hooks();
23 23
 
24 24
 		/** @var WordPoints_Hook_Reactor $reactor */
25
-		foreach ( $hooks->reactors->get_all() as $reactor ) {
25
+		foreach ($hooks->reactors->get_all() as $reactor) {
26 26
 
27
-			foreach ( $reactor->get_all_reactions_to_event( $event_slug ) as $reaction ) {
27
+			foreach ($reactor->get_all_reactions_to_event($event_slug) as $reaction) {
28 28
 
29 29
 				$validator = new WordPoints_Hook_Reaction_Validator(
30 30
 					$reaction
@@ -34,25 +34,25 @@  discard block
 block discarded – undo
34 34
 
35 35
 				$validator->validate();
36 36
 
37
-				if ( $validator->had_errors() ) {
37
+				if ($validator->had_errors()) {
38 38
 					continue;
39 39
 				}
40 40
 
41
-				$event_args->set_validator( $validator );
41
+				$event_args->set_validator($validator);
42 42
 				$reaction = $validator;
43 43
 
44 44
 				/** @var WordPoints_Hook_Extension $extension */
45
-				foreach ( $hooks->extensions->get_all() as $extension ) {
45
+				foreach ($hooks->extensions->get_all() as $extension) {
46 46
 
47
-					if ( ! $extension->should_hit( $reaction, $event_args ) ) {
47
+					if ( ! $extension->should_hit($reaction, $event_args)) {
48 48
 						continue 2;
49 49
 					}
50 50
 				}
51 51
 
52
-				$reactor->hit( $event_args, $reaction );
52
+				$reactor->hit($event_args, $reaction);
53 53
 
54 54
 				// TODO hook docs (is this hook even needed?)
55
-				do_action( 'wordpoints_hook_event_hit', $reaction, $event_args, $reactor );
55
+				do_action('wordpoints_hook_event_hit', $reaction, $event_args, $reactor);
56 56
 			}
57 57
 		}
58 58
 	}
Please login to merge, or discard this patch.
src/includes/classes/hook/firer/reverse.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,21 +17,21 @@
 block discarded – undo
17 17
 	/**
18 18
 	 * @since 1.0.0
19 19
 	 */
20
-	public function do_event( $event_slug, WordPoints_Hook_Event_Args $event_args ) {
20
+	public function do_event($event_slug, WordPoints_Hook_Event_Args $event_args) {
21 21
 
22 22
 		$hooks = wordpoints_hooks();
23 23
 
24
-		foreach ( $hooks->reactors->get_all() as $reactor ) {
24
+		foreach ($hooks->reactors->get_all() as $reactor) {
25 25
 
26
-			if ( ! ( $reactor instanceof WordPoints_Hook_Reactor_ReverseI ) ) {
26
+			if ( ! ($reactor instanceof WordPoints_Hook_Reactor_ReverseI)) {
27 27
 				continue;
28 28
 			}
29 29
 
30
-			$reactor->reverse_hits( $event_slug, $event_args );
30
+			$reactor->reverse_hits($event_slug, $event_args);
31 31
 
32
-			foreach ( $hooks->extensions->get_all() as $extension ) {
33
-				if ( $extension instanceof WordPoints_Hook_Extension_ReverseI ) {
34
-					$extension->after_reverse( $event_slug, $event_args, $reactor );
32
+			foreach ($hooks->extensions->get_all() as $extension) {
33
+				if ($extension instanceof WordPoints_Hook_Extension_ReverseI) {
34
+					$extension->after_reverse($event_slug, $event_args, $reactor);
35 35
 				}
36 36
 			}
37 37
 		}
Please login to merge, or discard this patch.
src/includes/classes/hook/firer/spam.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,21 +17,21 @@
 block discarded – undo
17 17
 	/**
18 18
 	 * @since 1.0.0
19 19
 	 */
20
-	public function do_event( $event_slug, WordPoints_Hook_Event_Args $event_args ) {
20
+	public function do_event($event_slug, WordPoints_Hook_Event_Args $event_args) {
21 21
 
22 22
 		$hooks = wordpoints_hooks();
23 23
 
24
-		foreach ( $hooks->reactors->get_all() as $reactor ) {
24
+		foreach ($hooks->reactors->get_all() as $reactor) {
25 25
 
26
-			if ( ! ( $reactor instanceof WordPoints_Hook_Reactor_SpamI ) ) {
26
+			if ( ! ($reactor instanceof WordPoints_Hook_Reactor_SpamI)) {
27 27
 				continue;
28 28
 			}
29 29
 
30
-			$reactor->spam_hits( $event_slug, $event_args );
30
+			$reactor->spam_hits($event_slug, $event_args);
31 31
 
32
-			foreach ( $hooks->extensions->get_all() as $extension ) {
33
-				if ( $extension instanceof WordPoints_Hook_Extension_SpamI ) {
34
-					$extension->after_spam( $event_slug, $event_args, $reactor );
32
+			foreach ($hooks->extensions->get_all() as $extension) {
33
+				if ($extension instanceof WordPoints_Hook_Extension_SpamI) {
34
+					$extension->after_spam($event_slug, $event_args, $reactor);
35 35
 				}
36 36
 			}
37 37
 		}
Please login to merge, or discard this patch.
src/includes/classes/hook/fireri.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	 * @param string                     $event_slug The event slug.
23 23
 	 * @param WordPoints_Hook_Event_Args $event_args The event args.
24 24
 	 */
25
-	public function do_event( $event_slug, WordPoints_Hook_Event_Args $event_args );
25
+	public function do_event($event_slug, WordPoints_Hook_Event_Args $event_args);
26 26
 }
27 27
 
28 28
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * @since 1.0.0
55 55
 	 */
56
-	public function __construct( $id, WordPoints_Hook_Reaction_StorageI $storage ) {
56
+	public function __construct($id, WordPoints_Hook_Reaction_StorageI $storage) {
57 57
 
58
-		$this->ID           = wordpoints_int( $id );
58
+		$this->ID           = wordpoints_int($id);
59 59
 		$this->storage      = $storage;
60 60
 		$this->reactor_slug = $this->storage->get_reactor_slug();
61 61
 		$this->network_wide = $this->storage->is_network_wide();
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 	/**
65 65
 	 * @since 1.0.0
66 66
 	 */
67
-	public function __get( $var ) {
67
+	public function __get($var) {
68 68
 
69
-		if ( 'ID' === $var ) {
69
+		if ('ID' === $var) {
70 70
 			return $this->ID;
71 71
 		}
72 72
 
Please login to merge, or discard this patch.