Completed
Push — master ( 975fd1...3e68e7 )
by J.D.
03:16
created
src/includes/classes/wpdb/wrapper.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -11,60 +11,60 @@  discard block
 block discarded – undo
11 11
 
12 12
 	protected $wpdb;
13 13
 
14
-	public function __construct( $wpdb ) {
14
+	public function __construct($wpdb) {
15 15
 		$this->wpdb = $wpdb;
16 16
 	}
17 17
 
18
-	public function __get( $name ) {
18
+	public function __get($name) {
19 19
 		return $this->wpdb->$name;
20 20
 	}
21 21
 
22
-	public function __set( $name, $value ) {
22
+	public function __set($name, $value) {
23 23
 		$this->wpdb->$name = $value;
24 24
 	}
25 25
 
26
-	public function __isset( $name ) {
27
-		return isset( $this->wpdb->$name );
26
+	public function __isset($name) {
27
+		return isset($this->wpdb->$name);
28 28
 	}
29 29
 
30
-	public function __unset( $name ) {
31
-		unset( $this->wpdb->$name );
30
+	public function __unset($name) {
31
+		unset($this->wpdb->$name);
32 32
 	}
33 33
 
34
-	public function __call( $name, $arguments ) {
34
+	public function __call($name, $arguments) {
35 35
 
36
-		$wrappers = wordpoints_apps()->get_sub_app( 'wpdb_wrappers' );
37
-		$slugs = $wrappers->get_child_slugs( $name );
36
+		$wrappers = wordpoints_apps()->get_sub_app('wpdb_wrappers');
37
+		$slugs = $wrappers->get_child_slugs($name);
38 38
 		$should_listen = $query = false;
39 39
 
40 40
 
41
-		switch ( $name ) {
41
+		switch ($name) {
42 42
 
43 43
 			case 'insert':
44 44
 //			case 'replace':
45
-				$query = new WordPoints_WPDB_Query_Data_Array( $this->args[0] );
45
+				$query = new WordPoints_WPDB_Query_Data_Array($this->args[0]);
46 46
 			break;
47 47
 
48 48
 			case 'update':
49
-				$query =  new WordPoints_WPDB_Query_Data_Array( $this->args[0], $this->args[2] );
49
+				$query = new WordPoints_WPDB_Query_Data_Array($this->args[0], $this->args[2]);
50 50
 			break;
51 51
 
52 52
 			case 'delete':
53
-				$query =  new WordPoints_WPDB_Query_Data_Array( $this->args[0], $this->args[1] );
53
+				$query = new WordPoints_WPDB_Query_Data_Array($this->args[0], $this->args[1]);
54 54
 			break;
55 55
 
56 56
 			case 'query':
57
-				$query =  new WordPoints_WPDB_Query_Data_SQL( $this->args[0] );
57
+				$query = new WordPoints_WPDB_Query_Data_SQL($this->args[0]);
58 58
 			break;
59 59
 		}
60 60
 
61
-		if ( $query ) {
61
+		if ($query) {
62 62
 			/** @var WordPoints_WPDB_Query_WrapperI $wrapper */
63
-			$wrapper = $wrappers->get( $name, $query );
63
+			$wrapper = $wrappers->get($name, $query);
64 64
 
65 65
 			$result = $wrapper->execute();
66 66
 		} else {
67
-			$result = call_user_func_array( array( $this->wpdb, $name ), $arguments );
67
+			$result = call_user_func_array(array($this->wpdb, $name), $arguments);
68 68
 		}
69 69
 
70 70
 		return $result;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 class WordPoints_MySQL_Query_Parser_Simple_Insert implements WordPoints_MySQL_Query_Parser_SimpleI {
86 86
 
87
-	public function __construct( $sql ) {
87
+	public function __construct($sql) {
88 88
 		$this->sql = $sql;
89 89
 	}
90 90
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		// columns will not be needed. then the other code can decide what to do.
100 100
 		// although I guess sense we have the tablel name we could reun the query
101 101
 		// ourselves if we need/want to.
102
-		if ( stripos( $this->sql, 'ON DUPLICATE KEY UPDATE' ) ) {
102
+		if (stripos($this->sql, 'ON DUPLICATE KEY UPDATE')) {
103 103
 
104 104
 		}
105 105
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	protected $parser;
121 121
 
122
-	public function __construct( $sql ) {
122
+	public function __construct($sql) {
123 123
 		$this->sql = $sql;
124 124
 		$this->parser = $this->get_parser();
125 125
 	}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		// of query it is.
131 131
 		// maybe the parser will actually be passed in, and the query type deterimed
132 132
 		// by teh method wrapper.
133
-		$parser = new WordPoints_MySQL_Query_Parser_Simple_Insert( $this->sql );
133
+		$parser = new WordPoints_MySQL_Query_Parser_Simple_Insert($this->sql);
134 134
 		// maybe we don't even need to parse.
135 135
 		return $parser;
136 136
 	}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	protected $table_name;
150 150
 	protected $where_data;
151 151
 
152
-	public function __construct( $table_name, $where_data = array() ) {
152
+	public function __construct($table_name, $where_data = array()) {
153 153
 		$this->table_name = $table_name;
154 154
 		$this->where_data = $where_data;
155 155
 	}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 }
165 165
 
166 166
 interface WordPoints_WPDB_Query_WrapperI {
167
-	public function __construct( $slug, $args, $wpdb );
167
+	public function __construct($slug, $args, $wpdb);
168 168
 	public function execute();
169 169
 
170 170
 }
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	protected $result;
186 186
 	protected $backed_up_wpdb_vars;
187 187
 
188
-	public function __construct( $slug, $args, $wpdb ) {
188
+	public function __construct($slug, $args, $wpdb) {
189 189
 		$this->slug = $slug;
190 190
 		$this->args = $args;
191 191
 		$this->wpdb = $wpdb;
@@ -194,20 +194,20 @@  discard block
 block discarded – undo
194 194
 
195 195
 	protected function get_query_data() {
196 196
 
197
-		switch ( $this->slug ) {
197
+		switch ($this->slug) {
198 198
 
199 199
 			case 'insert':
200 200
 				//			case 'replace':
201
-				return new WordPoints_WPDB_Query_Data_Array( $this->args[0] );
201
+				return new WordPoints_WPDB_Query_Data_Array($this->args[0]);
202 202
 
203 203
 			case 'update':
204
-				return new WordPoints_WPDB_Query_Data_Array( $this->args[0], $this->args[2] );
204
+				return new WordPoints_WPDB_Query_Data_Array($this->args[0], $this->args[2]);
205 205
 
206 206
 			case 'delete':
207
-				return new WordPoints_WPDB_Query_Data_Array( $this->args[0], $this->args[1] );
207
+				return new WordPoints_WPDB_Query_Data_Array($this->args[0], $this->args[1]);
208 208
 
209 209
 			case 'query':
210
-				return new WordPoints_WPDB_Query_Data_SQL( $this->args[0] );
210
+				return new WordPoints_WPDB_Query_Data_SQL($this->args[0]);
211 211
 		}
212 212
 
213 213
 		return false;
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 
218 218
 		$should_listen = $this->should_listen();
219 219
 
220
-		if ( $should_listen ) {
220
+		if ($should_listen) {
221 221
 			$this->before_query();
222 222
 		}
223 223
 
224
-		$this->result = call_user_func_array( array( $this->wpdb, $this->slug ), $this->args );
224
+		$this->result = call_user_func_array(array($this->wpdb, $this->slug), $this->args);
225 225
 
226
-		if ( $should_listen && $this->was_successful_query() ) {
226
+		if ($should_listen && $this->was_successful_query()) {
227 227
 			$this->backup_wpdb_vars();
228 228
 			$this->after_query();
229 229
 			$this->restore_wpdb_vars();
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 
253 253
 		// we could check for the availableility of eahc valu here in case of dropins
254 254
 		// or they become not available in the future.
255
-		foreach ( $to_backup as $property ) {
256
-			$this->backed_up_wpdb_vars[ $property ] = $this->wpdb->$property;
255
+		foreach ($to_backup as $property) {
256
+			$this->backed_up_wpdb_vars[$property] = $this->wpdb->$property;
257 257
 		}
258 258
 	}
259 259
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		// with the backed up result.
264 264
 		$this->wpdb->flush();
265 265
 
266
-		foreach ( $this->backed_up_wpdb_vars as $property => $value ) {
266
+		foreach ($this->backed_up_wpdb_vars as $property => $value) {
267 267
 			$this->wpdb->$property = $value;
268 268
 		}
269 269
 	}
@@ -301,18 +301,18 @@  discard block
 block discarded – undo
301 301
 	 */
302 302
 	protected function is_entity_table() {
303 303
 
304
-		$this->entity = 'new entity object' . $this->data->get_table_name();
304
+		$this->entity = 'new entity object'.$this->data->get_table_name();
305 305
 
306 306
 		return true;
307 307
 	}
308 308
 
309 309
 	public function should_listen() {
310 310
 
311
-		if ( ! $this->data ) {
311
+		if ( ! $this->data) {
312 312
 			return false;
313 313
 		}
314 314
 
315
-		if ( $this->is_entity_table() ) {
315
+		if ($this->is_entity_table()) {
316 316
 			return false;
317 317
 		}
318 318
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	}
321 321
 
322 322
 	protected function was_successful_query() {
323
-		return (bool) wordpoints_posint( $not_by_ref = $this->wpdb->num_rows );
323
+		return (bool) wordpoints_posint($not_by_ref = $this->wpdb->num_rows);
324 324
 	}
325 325
 }
326 326
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	protected $args;
331 331
 	protected $wpdb;
332 332
 
333
-	public function __construct( $slug, $args, $wpdb ) {
333
+	public function __construct($slug, $args, $wpdb) {
334 334
 		$this->slug = $slug;
335 335
 		$this->args = $args;
336 336
 		$this->wpdb = $wpdb;
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
 		// check if this is a query that we want to listen to.
342 342
 		// if so, call execute on a particular child.
343 343
 		// otherwise, just call execute.
344
-		if ( $this->get_query_type() ) {
344
+		if ($this->get_query_type()) {
345 345
 
346 346
 		} else {
347
-			$result = call_user_func_array( array( $this->wpdb, $this->slug ), $this->args );
347
+			$result = call_user_func_array(array($this->wpdb, $this->slug), $this->args);
348 348
 		}
349 349
 
350 350
 		return $result;
@@ -369,15 +369,15 @@  discard block
 block discarded – undo
369 369
 
370 370
 		$ids = $this->get_entity_ids();
371 371
 
372
-		$this->entities = new WordPoints_Entity_Array( $this->entity->get_slug() );
373
-		$this->entities->set_the_value( $ids );
372
+		$this->entities = new WordPoints_Entity_Array($this->entity->get_slug());
373
+		$this->entities->set_the_value($ids);
374 374
 	}
375 375
 
376 376
 	protected function get_entity_ids() {
377 377
 		$where = $this->data->get_where_clause();
378
-		$id_field = wordpoints_escape_mysql_identifier( $this->entity->get_id_field() );
379
-		$table_name = wordpoints_escape_mysql_identifier( $this->data->get_table_name() );
380
-		return $this->wpdb->get_col( "SELECT {$id_field} FROM {$table_name} {$where}" );
378
+		$id_field = wordpoints_escape_mysql_identifier($this->entity->get_id_field());
379
+		$table_name = wordpoints_escape_mysql_identifier($this->data->get_table_name());
380
+		return $this->wpdb->get_col("SELECT {$id_field} FROM {$table_name} {$where}");
381 381
 	}
382 382
 
383 383
 	protected function after_query() {
@@ -396,13 +396,13 @@  discard block
 block discarded – undo
396 396
 		$where_clause = $this->data->get_where_clause();
397 397
 
398 398
 		// get a before snapshot, if any matching are found.
399
-		if ( $where_clause ) {
399
+		if ($where_clause) {
400 400
 
401 401
 		}
402 402
 	}
403 403
 
404 404
 	protected function after_query() {
405
-		$this->entity->set_the_value( $this->wpdb->insert_id );
405
+		$this->entity->set_the_value($this->wpdb->insert_id);
406 406
 		// I guess we invoke the api to run the action now?
407 407
 		$this->trigger_entity_create_actions();
408 408
 	}
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 
414 414
 	protected function after_query() {
415 415
 		// I guess we invoke the api to run the action now?
416
-		$this->trigger_entity_delete_actions( $this->entities );
416
+		$this->trigger_entity_delete_actions($this->entities);
417 417
 	}
418 418
 }
419 419
 
Please login to merge, or discard this patch.
src/includes/classes/spec.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 interface WordPoints_SpecI {
12 12
 	public function get_title();
13 13
 	public function get_settings_fields();
14
-	public function validate_settings( $settings );
14
+	public function validate_settings($settings);
15 15
 	public function is_met();
16
-	public function get_error( $name );
16
+	public function get_error($name);
17 17
 }
18 18
 
19 19
 abstract class WordPoints_Spec implements  WordPoints_SpecI {
@@ -25,38 +25,38 @@  discard block
 block discarded – undo
25 25
 	 * @param $value
26 26
 	 * @param $expected
27 27
 	 */
28
-	public function __construct( $value, $expected ) {
28
+	public function __construct($value, $expected) {
29 29
 		$this->value = $value;
30 30
 		$this->expected = $expected;
31 31
 	}
32 32
 
33
-	public function validate_settings( $settings ) {
33
+	public function validate_settings($settings) {
34 34
 
35
-		$data_types = wordpoints_apps()->get_sub_app( 'data_types' );
35
+		$data_types = wordpoints_apps()->get_sub_app('data_types');
36 36
 
37
-		foreach ( $this->get_settings_fields() as $setting => $data ) {
37
+		foreach ($this->get_settings_fields() as $setting => $data) {
38 38
 
39
-			if ( ! isset( $settings[ $setting ] ) ) {
39
+			if ( ! isset($settings[$setting])) {
40 40
 
41
-				if ( ! empty( $data['required'] ) ) {
41
+				if ( ! empty($data['required'])) {
42 42
 					return 'error'; // TODO
43 43
 				}
44 44
 
45 45
 			} else {
46 46
 
47
-				$data_type = $data_types->get( $data['type'] );
47
+				$data_type = $data_types->get($data['type']);
48 48
 
49
-				if ( ! $data_type instanceof WordPoints_Data_TypeI ) {
49
+				if ( ! $data_type instanceof WordPoints_Data_TypeI) {
50 50
 					continue;
51 51
 				}
52 52
 
53
-				$value = $data_type->validate_value( $settings[ $setting ] );
53
+				$value = $data_type->validate_value($settings[$setting]);
54 54
 
55
-				if ( is_wp_error( $value ) ) {
55
+				if (is_wp_error($value)) {
56 56
 					return $value;
57 57
 				}
58 58
 
59
-				$settings[ $setting ] = $value;
59
+				$settings[$setting] = $value;
60 60
 			}
61 61
 		}
62 62
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 class WordPoints_Spec_Number_Max extends WordPoints_Spec {
68 68
 
69 69
 	public function get_title() {
70
-		return __( 'Maximum', 'wordpoints' );
70
+		return __('Maximum', 'wordpoints');
71 71
 	}
72 72
 
73 73
 	public function get_settings_fields() {
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 		return $this->value <= $this->expected;
86 86
 	}
87 87
 
88
-	public function get_error( $name ) {
88
+	public function get_error($name) {
89 89
 
90 90
 		return sprintf(
91
-			__( '%1$s must not be more than %2$s.', 'wordpoints' )
91
+			__('%1$s must not be more than %2$s.', 'wordpoints')
92 92
 			, $name
93 93
 			, $this->expected
94 94
 		);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 class WordPoints_Spec_String_Length_Max extends WordPoints_Spec {
99 99
 
100 100
 	public function get_title() {
101
-		return __( 'Maximum Length', 'wordpoints' );
101
+		return __('Maximum Length', 'wordpoints');
102 102
 	}
103 103
 
104 104
 	public function get_settings_fields() {
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 	}
113 113
 
114 114
 	public function is_met() {
115
-		return strlen( $this->value ) <= $this->expected;
115
+		return strlen($this->value) <= $this->expected;
116 116
 	}
117 117
 
118
-	public function get_error( $name ) {
118
+	public function get_error($name) {
119 119
 
120 120
 		return sprintf(
121
-			__( '%1$s must not be longer than %2$s characters.', 'wordpoints' )
121
+			__('%1$s must not be longer than %2$s characters.', 'wordpoints')
122 122
 			, $name
123 123
 			, $this->expected
124 124
 		);
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 class WordPoints_Spec_String_Contains extends WordPoints_Spec {
130 130
 
131 131
 	public function get_title() {
132
-		return __( 'Contains', 'wordpoints' );
132
+		return __('Contains', 'wordpoints');
133 133
 	}
134 134
 
135 135
 	public function get_settings_fields() {
136 136
 	}
137 137
 
138 138
 	public function is_met() {
139
-		return false !== strpos( $this->value, $this->expected );
139
+		return false !== strpos($this->value, $this->expected);
140 140
 	}
141 141
 
142
-	public function get_error( $name ) {
142
+	public function get_error($name) {
143 143
 
144 144
 		return sprintf(
145
-			__( '%1$s must contain "%2$s".', 'wordpoints' ) // TODO quotes
145
+			__('%1$s must contain "%2$s".', 'wordpoints') // TODO quotes
146 146
 			, $name
147 147
 			, $this->expected
148 148
 		);
@@ -165,19 +165,19 @@  discard block
 block discarded – undo
165 165
 	protected $validator;
166 166
 
167 167
 	public function get_title() {
168
-		return __( 'Contains', 'wordpoints' );
168
+		return __('Contains', 'wordpoints');
169 169
 	}
170 170
 
171 171
 	public function get_settings_fields() {
172 172
 		return array(
173 173
 			'min' => array(
174 174
 				'slug'  => 'min',
175
-				'label' => __( 'Minimum number of items', 'wordpoints' ),
175
+				'label' => __('Minimum number of items', 'wordpoints'),
176 176
 				'type'  => 'number',
177 177
 			),
178 178
 			'max' => array(
179 179
 				'slug'  => 'max',
180
-				'label' => __( 'Maximum number of items', 'wordpoints' ),
180
+				'label' => __('Maximum number of items', 'wordpoints'),
181 181
 				'type'  => 'number',
182 182
 			),
183 183
 		);
@@ -192,18 +192,18 @@  discard block
 block discarded – undo
192 192
 //		WordPoints_Hook_Reaction_Validator $validator
193 193
 	) {
194 194
 
195
-		if ( ! $this->arg_type_supported( $arg, $validator ) ) {
195
+		if ( ! $this->arg_type_supported($arg, $validator)) {
196 196
 			return false;
197 197
 		}
198 198
 
199 199
 		$this->settings = $settings;
200 200
 		$this->validator = $validator;
201 201
 
202
-		if ( ! $this->validate_count() ) {
202
+		if ( ! $this->validate_count()) {
203 203
 			return false;
204 204
 		}
205 205
 
206
-		if ( isset( $settings['conditions'] ) ) {
206
+		if (isset($settings['conditions'])) {
207 207
 			$this->validate_conditions();
208 208
 		}
209 209
 
@@ -213,21 +213,21 @@  discard block
 block discarded – undo
213 213
 	protected function validate_count() {
214 214
 
215 215
 		if (
216
-			! empty( $this->settings['max'] )
217
-			&& ! wordpoints_posint( $this->settings['max'] )
216
+			! empty($this->settings['max'])
217
+			&& ! wordpoints_posint($this->settings['max'])
218 218
 		) {
219 219
 			$this->validator->add_error(
220
-				__( 'The maximum must be a positive integer.', 'wordpoints' )
220
+				__('The maximum must be a positive integer.', 'wordpoints')
221 221
 				, 'max'
222 222
 			);
223 223
 		}
224 224
 
225 225
 		if (
226
-			! empty( $this->settings['min'] )
227
-			&& ! wordpoints_posint( $this->settings['min'] )
226
+			! empty($this->settings['min'])
227
+			&& ! wordpoints_posint($this->settings['min'])
228 228
 		) {
229 229
 			$this->validator->add_error(
230
-				__( 'The minimum must be a positive integer.', 'wordpoints' )
230
+				__('The minimum must be a positive integer.', 'wordpoints')
231 231
 				, 'min'
232 232
 			);
233 233
 		}
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 
238 238
 	protected function validate_conditions() {
239 239
 
240
-		$conditions_extension = wordpoints_hooks()->get_sub_app( 'extensions' )->get(
240
+		$conditions_extension = wordpoints_hooks()->get_sub_app('extensions')->get(
241 241
 			'conditions'
242 242
 		);
243 243
 
244 244
 		$conditions = $conditions_extension->validate_settings(
245
-			array( 'conditions' => $this->settings['conditions'] )
245
+			array('conditions' => $this->settings['conditions'])
246 246
 			, $this->validator
247 247
 			, $this->validator->get_event_args()
248 248
 		);
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
 
253 253
 	public function is_met() {
254 254
 
255
-		$entities = $this->filter_entities( $this->value );
255
+		$entities = $this->filter_entities($this->value);
256 256
 
257
-		return $this->check_count( count( $entities ) );
257
+		return $this->check_count(count($entities));
258 258
 	}
259 259
 
260 260
 	/**
@@ -266,41 +266,41 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return WordPoints_Entity[]
268 268
 	 */
269
-	protected function filter_entities( $entities ) {
269
+	protected function filter_entities($entities) {
270 270
 
271
-		$conditions_extension = wordpoints_hooks()->get_sub_app( 'extensions' )->get(
271
+		$conditions_extension = wordpoints_hooks()->get_sub_app('extensions')->get(
272 272
 			'conditions'
273 273
 		);
274 274
 
275
-		foreach ( $entities as $index => $entity ) {
275
+		foreach ($entities as $index => $entity) {
276 276
 
277 277
 			$matches = $conditions_extension->conditions_are_met(
278 278
 				$this->expected['conditions']
279
-				, new WordPoints_Hook_Event_Args( array( $entity ) )
279
+				, new WordPoints_Hook_Event_Args(array($entity))
280 280
 			);
281 281
 
282
-			if ( ! $matches ) {
283
-				unset( $entities[ $index ] );
282
+			if ( ! $matches) {
283
+				unset($entities[$index]);
284 284
 			}
285 285
 		}
286 286
 
287 287
 		return $entities;
288 288
 	}
289 289
 
290
-	protected function check_count( $count ) {
290
+	protected function check_count($count) {
291 291
 
292
-		if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) {
292
+		if (isset($this->settings['max']) && $count > $this->settings['max']) {
293 293
 			return false;
294 294
 		}
295 295
 
296
-		if ( isset( $this->settings['min'] ) && $count < $this->settings['min'] ) {
296
+		if (isset($this->settings['min']) && $count < $this->settings['min']) {
297 297
 			return false;
298 298
 		}
299 299
 
300 300
 		return true;
301 301
 	}
302 302
 
303
-	public function get_error( $name ) {
303
+	public function get_error($name) {
304 304
 		// TODO: Implement get_error() method.
305 305
 	}
306 306
 }
Please login to merge, or discard this patch.
src/includes/classes/hooks.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
 	protected function init() {
41 41
 
42 42
 		$sub_apps = $this->sub_apps;
43
-		$sub_apps->register( 'router', 'WordPoints_Hook_Router' );
44
-		$sub_apps->register( 'actions', 'WordPoints_Hook_Actions' );
45
-		$sub_apps->register( 'events', 'WordPoints_Hook_Events' );
46
-		$sub_apps->register( 'reactors', 'WordPoints_Class_Registry_Persistent' );
47
-		$sub_apps->register( 'reaction_stores', 'WordPoints_Class_Registry_Children' );
48
-		$sub_apps->register( 'extensions', 'WordPoints_Class_Registry_Persistent' );
49
-		$sub_apps->register( 'conditions', 'WordPoints_Class_Registry_Children' );
43
+		$sub_apps->register('router', 'WordPoints_Hook_Router');
44
+		$sub_apps->register('actions', 'WordPoints_Hook_Actions');
45
+		$sub_apps->register('events', 'WordPoints_Hook_Events');
46
+		$sub_apps->register('reactors', 'WordPoints_Class_Registry_Persistent');
47
+		$sub_apps->register('reaction_stores', 'WordPoints_Class_Registry_Children');
48
+		$sub_apps->register('extensions', 'WordPoints_Class_Registry_Persistent');
49
+		$sub_apps->register('conditions', 'WordPoints_Class_Registry_Children');
50 50
 
51 51
 		parent::init();
52 52
 	}
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function get_current_mode() {
71 71
 
72
-		if ( ! isset( $this->current_mode ) ) {
73
-			$this->current_mode = ( wordpoints_is_network_context() ? 'network' : 'standard' );
72
+		if ( ! isset($this->current_mode)) {
73
+			$this->current_mode = (wordpoints_is_network_context() ? 'network' : 'standard');
74 74
 		}
75 75
 
76 76
 		return $this->current_mode;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @param string $mode The slug of the mode to set as the current mode.
90 90
 	 */
91
-	public function set_current_mode( $mode ) {
91
+	public function set_current_mode($mode) {
92 92
 		$this->current_mode = $mode;
93 93
 	}
94 94
 
@@ -101,19 +101,19 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return WordPoints_Hook_Reaction_StoreI|false The reaction storage object.
103 103
 	 */
104
-	public function get_reaction_store( $slug ) {
104
+	public function get_reaction_store($slug) {
105 105
 
106
-		$reaction_store = $this->get_sub_app( 'reaction_stores' )->get(
106
+		$reaction_store = $this->get_sub_app('reaction_stores')->get(
107 107
 			$this->get_current_mode()
108 108
 			, $slug
109 109
 		);
110 110
 
111
-		if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) {
111
+		if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) {
112 112
 			return false;
113 113
 		}
114 114
 
115 115
 		// Allowing access to stores out-of-context would lead to strange behavior.
116
-		if ( false === $reaction_store->get_context_id() ) {
116
+		if (false === $reaction_store->get_context_id()) {
117 117
 			return false;
118 118
 		}
119 119
 
@@ -136,19 +136,19 @@  discard block
 block discarded – undo
136 136
 		$action_type
137 137
 	) {
138 138
 
139
-		foreach ( $this->get_sub_app( 'reaction_stores' )->get_all() as $reaction_stores ) {
140
-			foreach ( $reaction_stores as $reaction_store ) {
139
+		foreach ($this->get_sub_app('reaction_stores')->get_all() as $reaction_stores) {
140
+			foreach ($reaction_stores as $reaction_store) {
141 141
 
142
-				if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) {
142
+				if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) {
143 143
 					continue;
144 144
 				}
145 145
 
146 146
 				// Allowing access to stores out-of-context would lead to strange behavior.
147
-				if ( false === $reaction_store->get_context_id() ) {
147
+				if (false === $reaction_store->get_context_id()) {
148 148
 					continue;
149 149
 				}
150 150
 
151
-				foreach ( $reaction_store->get_reactions_to_event( $event_slug ) as $reaction ) {
151
+				foreach ($reaction_store->get_reactions_to_event($event_slug) as $reaction) {
152 152
 
153 153
 					$fire = new WordPoints_Hook_Fire(
154 154
 						$event_args
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 						, $action_type
157 157
 					);
158 158
 
159
-					$this->fire_reaction( $fire );
159
+					$this->fire_reaction($fire);
160 160
 				}
161 161
 			}
162 162
 		}
@@ -169,32 +169,32 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @param WordPoints_Hook_Fire $fire The hook fire object.
171 171
 	 */
172
-	protected function fire_reaction( $fire ) {
172
+	protected function fire_reaction($fire) {
173 173
 
174 174
 		/** @var WordPoints_Hook_ReactorI $reactor */
175
-		$reactor = $this->get_sub_app( 'reactors' )->get( $fire->reaction->get_reactor_slug() );
175
+		$reactor = $this->get_sub_app('reactors')->get($fire->reaction->get_reactor_slug());
176 176
 
177
-		if ( ! in_array( $fire->action_type, $reactor->get_action_types(), true ) ) {
177
+		if ( ! in_array($fire->action_type, $reactor->get_action_types(), true)) {
178 178
 			return;
179 179
 		}
180 180
 
181
-		$validator = new WordPoints_Hook_Reaction_Validator( $fire->reaction, true );
181
+		$validator = new WordPoints_Hook_Reaction_Validator($fire->reaction, true);
182 182
 		$validator->validate();
183 183
 
184
-		if ( $validator->had_errors() ) {
184
+		if ($validator->had_errors()) {
185 185
 			return;
186 186
 		}
187 187
 
188
-		unset( $validator );
188
+		unset($validator);
189 189
 
190 190
 		/** @var WordPoints_Hook_ExtensionI[] $extensions */
191
-		$extensions = $this->get_sub_app( 'extensions' )->get_all();
191
+		$extensions = $this->get_sub_app('extensions')->get_all();
192 192
 
193
-		foreach ( $extensions as $extension ) {
194
-			if ( ! $extension->should_hit( $fire ) ) {
195
-				foreach ( $extensions as $ext ) {
196
-					if ( $ext instanceof WordPoints_Hook_Extension_Miss_ListenerI ) {
197
-						$ext->after_miss( $fire );
193
+		foreach ($extensions as $extension) {
194
+			if ( ! $extension->should_hit($fire)) {
195
+				foreach ($extensions as $ext) {
196
+					if ($ext instanceof WordPoints_Hook_Extension_Miss_ListenerI) {
197
+						$ext->after_miss($fire);
198 198
 					}
199 199
 				}
200 200
 
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 
205 205
 		$fire->hit();
206 206
 
207
-		$reactor->hit( $fire );
207
+		$reactor->hit($fire);
208 208
 
209
-		foreach ( $extensions as $extension ) {
210
-			if ( $extension instanceof WordPoints_Hook_Extension_Hit_ListenerI ) {
211
-				$extension->after_hit( $fire );
209
+		foreach ($extensions as $extension) {
210
+			if ($extension instanceof WordPoints_Hook_Extension_Hit_ListenerI) {
211
+				$extension->after_hit($fire);
212 212
 			}
213 213
 		}
214 214
 	}
Please login to merge, or discard this patch.
src/includes/classes/entity/change.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -10,19 +10,19 @@  discard block
 block discarded – undo
10 10
 // this is basicaly a router.
11 11
 class WordPoints_Entity_chang_trigger implements WordPoints_Entity_Change_ListenerI {
12 12
 
13
-	public function created( WordPoints_Entity $entity ) {
13
+	public function created(WordPoints_Entity $entity) {
14 14
 		// can multiple entities be created at once? not using insert() but via query()
15 15
 		// maybe? and how shoudl we handle that, all at once or one by one?
16 16
 
17 17
 		/** @var WordPoints_Entity_Change_ListenerI[] $listeners */
18
-		$listeners = wordpoints_apps()->get_sub_app( 'entity_change_listeners' );
19
-		foreach ( $listeners as $listener ) {
20
-			$listener->created( $entity );
18
+		$listeners = wordpoints_apps()->get_sub_app('entity_change_listeners');
19
+		foreach ($listeners as $listener) {
20
+			$listener->created($entity);
21 21
 		}
22 22
 	}
23 23
 
24 24
 
25
-	public function updated( WordPoints_Entity $before, WordPoints_Entity $after ) {
25
+	public function updated(WordPoints_Entity $before, WordPoints_Entity $after) {
26 26
 
27 27
 		// what if multiple entities are updated at once? do we run each one separatately?
28 28
 		// mayb ethat should be left up to the listenter.
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	}
31 31
 
32 32
 
33
-	public function deleted( WordPoints_Entity $entity ) {
33
+	public function deleted(WordPoints_Entity $entity) {
34 34
 
35 35
 		// what if we need information about this entitie's relationships, etc., that
36 36
 		// isn't included inthe entity object?
@@ -58,41 +58,41 @@  discard block
 block discarded – undo
58 58
 
59 59
 // this is basically a reactor
60 60
 interface WordPoints_Entity_Change_ListenerI {
61
-	public function created( WordPoints_Entity $entity );
62
-	public function updated( WordPoints_Entity $before, WordPoints_Entity $after );
63
-	public function deleted( WordPoints_Entity $entity );
61
+	public function created(WordPoints_Entity $entity);
62
+	public function updated(WordPoints_Entity $before, WordPoints_Entity $after);
63
+	public function deleted(WordPoints_Entity $entity);
64 64
 }
65 65
 
66 66
 class WordPoints_Entity_Change_Listener_Hooks implements WordPoints_Entity_Change_ListenerI {
67 67
 
68
-	public function created( WordPoints_Entity $entity ) {
68
+	public function created(WordPoints_Entity $entity) {
69 69
 
70 70
 		// maybe we would have multuiple events with requirements for a single entity?
71 71
 		// like comment author and post commentn author targets for the same hook.
72 72
 		// but I guess taht is just one event.
73 73
 		// what about user register vs user create on MS?
74
-		if ( $this->matches_requirements( $entity ) ) {
75
-			$this->fire_event( 'add', $entity );
74
+		if ($this->matches_requirements($entity)) {
75
+			$this->fire_event('add', $entity);
76 76
 		}
77 77
 	}
78 78
 
79
-	public function updated( WordPoints_Entity $before, WordPoints_Entity $after ) {
79
+	public function updated(WordPoints_Entity $before, WordPoints_Entity $after) {
80 80
 
81
-		if ( $this->matches_requirements( $after ) ) {
82
-			if ( ! $this->matches_requirements( $before ) ) {
83
-				$this->fire_event( 'add', $after );
81
+		if ($this->matches_requirements($after)) {
82
+			if ( ! $this->matches_requirements($before)) {
83
+				$this->fire_event('add', $after);
84 84
 			}
85 85
 		} else {
86
-			if ( $this->matches_requirements( $before ) ) {
87
-				$this->fire_event( 'remove', $after );
86
+			if ($this->matches_requirements($before)) {
87
+				$this->fire_event('remove', $after);
88 88
 			}
89 89
 		}
90 90
 	}
91 91
 
92
-	public function deleted( WordPoints_Entity $entity ) {
92
+	public function deleted(WordPoints_Entity $entity) {
93 93
 
94
-		if ( $this->matches_requirements( $entity ) ) {
95
-			$this->fire_event( 'remove', $entity );
94
+		if ($this->matches_requirements($entity)) {
95
+			$this->fire_event('remove', $entity);
96 96
 		}
97 97
 	}
98 98
 
@@ -108,20 +108,20 @@  discard block
 block discarded – undo
108 108
 	// called into play when the entity itself is deleted is moot, because the
109 109
 	// reltionships, etc., aren't even taken into account when toggle-off is called,
110 110
 	// in the points reactor. other reators might, i guess.
111
-	protected function matches_requirements( WordPoints_Entity $entity ) {
111
+	protected function matches_requirements(WordPoints_Entity $entity) {
112 112
 
113 113
 		/** @var WordPoints_Class_Registry $defaults */
114
-		$defaults = wordpoints_apps()->get_sub_app( 'entity_possession_defaults' );
114
+		$defaults = wordpoints_apps()->get_sub_app('entity_possession_defaults');
115 115
 
116
-		$defaults = $defaults->get( $entity->get_slug() );
116
+		$defaults = $defaults->get($entity->get_slug());
117 117
 
118
-		if ( ! $defaults ) {
118
+		if ( ! $defaults) {
119 119
 			return false;
120 120
 		}
121 121
 
122 122
 		// use conditions here?
123
-		foreach ( $defaults as $child => $value ) {
124
-			if ( $entity->get_child( $child ) !== $value ) {
123
+		foreach ($defaults as $child => $value) {
124
+			if ($entity->get_child($child) !== $value) {
125 125
 				return false;
126 126
 			}
127 127
 		}
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 		return true;
130 130
 	}
131 131
 
132
-	protected function fire_event( $type, WordPoints_Entity $entity ) {
132
+	protected function fire_event($type, WordPoints_Entity $entity) {
133 133
 
134
-		$args = new WordPoints_Hook_Event_Args( array() );
135
-		$args->add_entity( $entity );
134
+		$args = new WordPoints_Hook_Event_Args(array());
135
+		$args->add_entity($entity);
136 136
 
137 137
 		wordpoints_hooks()->fire(
138
-			$type . '_entity_' . $entity->get_slug(),
138
+			$type.'_entity_'.$entity->get_slug(),
139 139
 			$args,
140 140
 			'toggle_on'
141 141
 		);
@@ -144,31 +144,31 @@  discard block
 block discarded – undo
144 144
 
145 145
 class WordPoints_Entity_Change_Listener_Points implements WordPoints_Entity_Change_ListenerI {
146 146
 
147
-	public function created( WordPoints_Entity $entity ) {
147
+	public function created(WordPoints_Entity $entity) {
148 148
 
149 149
 		$this->process_entityish(
150 150
 			$entity
151
-			, $this->get_settings_for_entity( $entity )
151
+			, $this->get_settings_for_entity($entity)
152 152
 		);
153 153
 	}
154 154
 
155
-	protected function process_entityish( WordPoints_EntityishI $entity, $settings ) {
155
+	protected function process_entityish(WordPoints_EntityishI $entity, $settings) {
156 156
 
157 157
 		// possibly make this more like extension handling
158
-		if ( ! $this->meets_conditions( $entity, $settings['conditions'] ) ) {
158
+		if ( ! $this->meets_conditions($entity, $settings['conditions'])) {
159 159
 			return;
160 160
 		}
161 161
 
162 162
 		// possibly make this more like reactor handling.
163
-		$this->award_points( $settings );
163
+		$this->award_points($settings);
164 164
 
165 165
 		// only proces the attributes taht have changed.
166 166
 		// acutally, in this case, the entity was just created.
167
-		if ( $entity instanceof WordPoints_Entity_ParentI ) {
167
+		if ($entity instanceof WordPoints_Entity_ParentI) {
168 168
 
169 169
 			// this check runs on attributes only.
170
-			foreach ( $settings['children'] as $child_slug => $child_settings ) {
171
-				$this->process_entityish( $entity->get_child( $child_slug ), $child_settings );
170
+			foreach ($settings['children'] as $child_slug => $child_settings) {
171
+				$this->process_entityish($entity->get_child($child_slug), $child_settings);
172 172
 			}
173 173
 
174 174
 			// we also need to check for any children, like relationships, that have
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 			// for this we need a list of relationships.
177 177
 			// if we do two-way relationships, we may need to have infinite-loop
178 178
 			// halding here, depending.
179
-			foreach ( $this->get_related_entities( $entity ) as $child_entity ) {
179
+			foreach ($this->get_related_entities($entity) as $child_entity) {
180 180
 				// If a comment was just created, for example, and we have conditions
181 181
 				// on the post entity, that affect the comment author, this allows
182 182
 				// us to handle those by pulling up the settings for the post entity
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 				// as we've proposed...
196 196
 				$this->process_entityish(
197 197
 					$child_entity
198
-					, $this->get_entity_settings( $child_entity )
198
+					, $this->get_entity_settings($child_entity)
199 199
 				);
200 200
 			}
201 201
 		}
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
 	// doesn't really make sense.
210 210
 	// I think relationships can be created and deleted, but not really updated.
211 211
 	// so maybe what we need is a separate api?
212
-	public function updated( WordPoints_Entity $before, WordPoints_Entity $after ) {
212
+	public function updated(WordPoints_Entity $before, WordPoints_Entity $after) {
213 213
 
214
-		$settings = $this->get_settings_for_entity( $before );
214
+		$settings = $this->get_settings_for_entity($before);
215 215
 
216 216
 		/** @var WordPoints_Class_Registry_ChildrenI $children */
217
-		$children = wordpoints_entities()->get_sub_app( 'children' );
218
-		foreach ( $children->get_children_slugs( $before->get_slug() ) as $child_slug ) {
217
+		$children = wordpoints_entities()->get_sub_app('children');
218
+		foreach ($children->get_children_slugs($before->get_slug()) as $child_slug) {
219 219
 			
220
-			if ( ! isset( $settings['children'][ $child_slug ] ) ) {
220
+			if ( ! isset($settings['children'][$child_slug])) {
221 221
 				continue;
222 222
 			}
223 223
 			
@@ -232,23 +232,23 @@  discard block
 block discarded – undo
232 232
 			// but then we'll not be checking even the relationships taht are defined
233 233
 			// on the atts. so we have to decide whether those should be handled by
234 234
 			// a separate api or not.
235
-			if ( $before->get_the_attr_value( $child_slug ) === $after->get_the_attr_value( $child_slug ) ) {
235
+			if ($before->get_the_attr_value($child_slug) === $after->get_the_attr_value($child_slug)) {
236 236
 				continue;
237 237
 			}
238 238
 
239 239
 			$this->process_modified_entityish(
240
-				$before->get_child( $child_slug )
241
-				, $after->get_child( $child_slug )
242
-				, $settings['children'][ $child_slug ]
240
+				$before->get_child($child_slug)
241
+				, $after->get_child($child_slug)
242
+				, $settings['children'][$child_slug]
243 243
 			);
244 244
 		}
245 245
 	}
246 246
 
247
-	protected function process_modified_entityish( WordPoints_EntityishI $before, WordPoints_EntityishI $after, $settings ) {
247
+	protected function process_modified_entityish(WordPoints_EntityishI $before, WordPoints_EntityishI $after, $settings) {
248 248
 
249
-		if ( ! $this->meets_conditions( $before, $settings['conditions'] ) ) {
250
-			if ( $this->meets_conditions( $after, $settings['conditions'] ) ) {
251
-				$this->award_points( $settings );
249
+		if ( ! $this->meets_conditions($before, $settings['conditions'])) {
250
+			if ($this->meets_conditions($after, $settings['conditions'])) {
251
+				$this->award_points($settings);
252 252
 
253 253
 				// also need to process other eneities that are affected by this
254 254
 				// change, which may have conditions on this, i.e., that could be
@@ -265,38 +265,38 @@  discard block
 block discarded – undo
265 265
 				// then we do indeed need to run through the children/parents.
266 266
 			}
267 267
 		} else {
268
-			if ( ! $this->meets_conditions( $after, $settings['conditions'] ) ) {
269
-				$this->remove_points( $settings );
268
+			if ( ! $this->meets_conditions($after, $settings['conditions'])) {
269
+				$this->remove_points($settings);
270 270
 			}
271 271
 		}
272 272
 	}
273 273
 
274
-	public function deleted( WordPoints_Entity $entity ) {
274
+	public function deleted(WordPoints_Entity $entity) {
275 275
 		// basically the opposite of created().
276
-		$this->process_entityish_reverse( $entity );
276
+		$this->process_entityish_reverse($entity);
277 277
 	}
278 278
 
279
-	protected function meets_conditions( WordPoints_EntityishI $entityish, $conditions ) {
279
+	protected function meets_conditions(WordPoints_EntityishI $entityish, $conditions) {
280 280
 		// use conditions api
281 281
 
282 282
 		return false;
283 283
 	}
284 284
 
285
-	private function award_points( $settings ) {
285
+	private function award_points($settings) {
286 286
 
287
-		$hierarchy = new WordPoints_Entity_Hierarchy( $this->eitnty );
287
+		$hierarchy = new WordPoints_Entity_Hierarchy($this->eitnty);
288 288
 		// todo we'll need to introudce entity array targets, possibly.
289 289
 		// how will we know how to reverse the target reltinoship chains in the UI
290 290
 		// before saving? i guess we'll need to either have a dedicated index fo taht
291 291
 		// or else juust look it up by looping through the relationships (though we'd
292 292
 		// have to remove the entity array {} part from any one-to-many relationships
293 293
 		// and maybe we'd have to add it to others?)
294
-		$targets = $hierarchy->get_from_hierarchy( $settings['target'] );
294
+		$targets = $hierarchy->get_from_hierarchy($settings['target']);
295 295
 
296 296
 		// maybe just one target, maybe several, depending.
297 297
 	}
298 298
 
299
-	private function get_related_entities( WordPoints_Entity $entity ) {
299
+	private function get_related_entities(WordPoints_Entity $entity) {
300 300
 
301 301
 		// what we need is parental conditions. Conditions that go up the chain,
302 302
 		// and look back at parent entities. This way we can handle the info about
Please login to merge, or discard this patch.
src/includes/classes/app.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
 	/**
95 95
 	 * @since 1.0.0
96 96
 	 */
97
-	public function __construct( $slug, $parent = null ) {
97
+	public function __construct($slug, $parent = null) {
98 98
 
99 99
 		$this->slug = $slug;
100 100
 		$this->full_slug = $slug;
101 101
 
102
-		if ( $parent instanceof WordPoints_App ) {
102
+		if ($parent instanceof WordPoints_App) {
103 103
 			$this->parent = $parent;
104 104
 
105
-			if ( 'apps' !== $this->parent->full_slug ) {
106
-				$this->full_slug = $this->parent->full_slug . '-' . $this->full_slug;
105
+			if ('apps' !== $this->parent->full_slug) {
106
+				$this->full_slug = $this->parent->full_slug.'-'.$this->full_slug;
107 107
 			}
108 108
 		}
109 109
 
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return null|object|WordPoints_App|WordPoints_Class_RegistryI|WordPoints_Class_Registry_ChildrenI The sub app, or null if not found.
123 123
 	 */
124
-	public function get_sub_app( $slug ) {
124
+	public function get_sub_app($slug) {
125 125
 
126
-		$sub_app = $this->sub_apps->get( $slug, array( $this ) );
126
+		$sub_app = $this->sub_apps->get($slug, array($this));
127 127
 
128
-		if ( ! $sub_app ) {
128
+		if ( ! $sub_app) {
129 129
 			return null;
130 130
 		}
131 131
 
132 132
 		if (
133
-			empty( $this->did_init[ $slug ] )
133
+			empty($this->did_init[$slug])
134 134
 			&& ! self::$main->silent
135
-			&& $this->should_do_registry_init( $sub_app )
135
+			&& $this->should_do_registry_init($sub_app)
136 136
 		) {
137 137
 
138
-			$this->did_init[ $slug ] = true;
138
+			$this->did_init[$slug] = true;
139 139
 
140 140
 			/**
141 141
 			 * Initialization of an app registry.
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			 * @param WordPoints_Class_RegistryI|WordPoints_Class_Registry_ChildrenI
148 148
 			 *        $registry The registry object.
149 149
 			 */
150
-			do_action( "wordpoints_init_app_registry-{$this->full_slug}-{$slug}", $sub_app );
150
+			do_action("wordpoints_init_app_registry-{$this->full_slug}-{$slug}", $sub_app);
151 151
 		}
152 152
 
153 153
 		return $sub_app;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @return bool Whether to call the init action or not.
175 175
 	 */
176
-	protected function should_do_registry_init( $registry ) {
176
+	protected function should_do_registry_init($registry) {
177 177
 		return (
178 178
 		   $registry instanceof WordPoints_Class_RegistryI
179 179
 		   || $registry instanceof WordPoints_Class_Registry_ChildrenI
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		 *
198 198
 		 * @param WordPoints_App $app The app object.
199 199
 		 */
200
-		do_action( "wordpoints_init_app-{$this->full_slug}", $this );
200
+		do_action("wordpoints_init_app-{$this->full_slug}", $this);
201 201
 	}
202 202
 }
203 203
 
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 	 * @param int                             $id    The ID of a hook reaction.
41 41
 	 * @param WordPoints_Hook_Reaction_StoreI $store The storage object.
42 42
 	 */
43
-	public function __construct( $id, WordPoints_Hook_Reaction_StoreI $store ) {
43
+	public function __construct($id, WordPoints_Hook_Reaction_StoreI $store) {
44 44
 
45
-		$this->ID    = wordpoints_int( $id );
45
+		$this->ID    = wordpoints_int($id);
46 46
 		$this->store = $store;
47 47
 	}
48 48
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @since 1.0.0
70 70
 	 */
71 71
 	public function get_reactor_slug() {
72
-		return $this->get_meta( 'reactor' );
72
+		return $this->get_meta('reactor');
73 73
 	}
74 74
 
75 75
 	/**
Please login to merge, or discard this patch.
src/includes/classes/hook/router.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	/**
90 90
 	 * @since 1.0.0
91 91
 	 */
92
-	public function __call( $name, $args ) {
92
+	public function __call($name, $args) {
93 93
 
94
-		$this->route_action( $name, $args );
94
+		$this->route_action($name, $args);
95 95
 
96 96
 		// Return the first value, in case it is hooked to a filter.
97 97
 		$return = null;
98
-		if ( isset( $args[0] ) ) {
98
+		if (isset($args[0])) {
99 99
 			$return = $args[0];
100 100
 		}
101 101
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 	 *                     action name and the priority.
113 113
 	 * @param array  $args The args the action was fired with.
114 114
 	 */
115
-	protected function route_action( $name, $args ) {
115
+	protected function route_action($name, $args) {
116 116
 
117
-		if ( ! isset( $this->action_index[ $name ] ) ) {
117
+		if ( ! isset($this->action_index[$name])) {
118 118
 			return;
119 119
 		}
120 120
 
@@ -122,48 +122,48 @@  discard block
 block discarded – undo
122 122
 		// registry attempts to access the router in its own constructor. The result
123 123
 		// of attempting to do this before the router itself has been fully
124 124
 		// constructed is that the events registry gets null instead of the router.
125
-		if ( ! isset( $this->hooks ) ) {
125
+		if ( ! isset($this->hooks)) {
126 126
 
127 127
 			$hooks = wordpoints_hooks();
128 128
 
129 129
 			$this->hooks   = $hooks;
130
-			$this->events  = $hooks->get_sub_app( 'events' );
131
-			$this->actions = $hooks->get_sub_app( 'actions' );
132
-			$this->event_args = $this->events->get_sub_app( 'args' );
130
+			$this->events  = $hooks->get_sub_app('events');
131
+			$this->actions = $hooks->get_sub_app('actions');
132
+			$this->event_args = $this->events->get_sub_app('args');
133 133
 		}
134 134
 
135
-		foreach ( $this->action_index[ $name ]['actions'] as $slug => $data ) {
135
+		foreach ($this->action_index[$name]['actions'] as $slug => $data) {
136 136
 
137
-			if ( ! isset( $this->event_index[ $slug ] ) ) {
137
+			if ( ! isset($this->event_index[$slug])) {
138 138
 				continue;
139 139
 			}
140 140
 
141
-			$action_object = $this->actions->get( $slug, $args, $data );
141
+			$action_object = $this->actions->get($slug, $args, $data);
142 142
 
143
-			if ( ! ( $action_object instanceof WordPoints_Hook_ActionI ) ) {
143
+			if ( ! ($action_object instanceof WordPoints_Hook_ActionI)) {
144 144
 				continue;
145 145
 			}
146 146
 
147
-			if ( ! $action_object->should_fire() ) {
147
+			if ( ! $action_object->should_fire()) {
148 148
 				continue;
149 149
 			}
150 150
 
151
-			foreach ( $this->event_index[ $slug ] as $type => $events ) {
152
-				foreach ( $events as $event_slug => $unused ) {
151
+			foreach ($this->event_index[$slug] as $type => $events) {
152
+				foreach ($events as $event_slug => $unused) {
153 153
 
154
-					if ( ! $this->events->is_registered( $event_slug ) ) {
154
+					if ( ! $this->events->is_registered($event_slug)) {
155 155
 						continue;
156 156
 					}
157 157
 
158
-					$event_args = $this->event_args->get_children( $event_slug, array( $action_object ) );
158
+					$event_args = $this->event_args->get_children($event_slug, array($action_object));
159 159
 
160
-					if ( empty( $event_args ) ) {
160
+					if (empty($event_args)) {
161 161
 						continue;
162 162
 					}
163 163
 
164
-					$event_args = new WordPoints_Hook_Event_Args( $event_args );
164
+					$event_args = new WordPoints_Hook_Event_Args($event_args);
165 165
 
166
-					$this->hooks->fire( $event_slug, $event_args, $type );
166
+					$this->hooks->fire($event_slug, $event_args, $type);
167 167
 				}
168 168
 			}
169 169
 		}
@@ -192,56 +192,56 @@  discard block
 block discarded – undo
192 192
 	 *        }
193 193
 	 * }
194 194
 	 */
195
-	public function add_action( $slug, array $args ) {
195
+	public function add_action($slug, array $args) {
196 196
 
197 197
 		$priority = 10;
198
-		if ( isset( $args['priority'] ) ) {
198
+		if (isset($args['priority'])) {
199 199
 			$priority = $args['priority'];
200 200
 		}
201 201
 
202
-		if ( ! isset( $args['action'] ) ) {
202
+		if ( ! isset($args['action'])) {
203 203
 			return;
204 204
 		}
205 205
 
206 206
 		$method = "{$args['action']},{$priority}";
207 207
 
208
-		$this->action_index[ $method ]['actions'][ $slug ] = array();
208
+		$this->action_index[$method]['actions'][$slug] = array();
209 209
 
210 210
 		$arg_number = 1;
211 211
 
212
-		if ( isset( $args['data'] ) ) {
212
+		if (isset($args['data'])) {
213 213
 
214
-			if ( isset( $args['data']['arg_index'] ) ) {
215
-				$arg_number = 1 + max( $args['data']['arg_index'] );
214
+			if (isset($args['data']['arg_index'])) {
215
+				$arg_number = 1 + max($args['data']['arg_index']);
216 216
 			}
217 217
 
218
-			if ( isset( $args['data']['requirements'] ) ) {
219
-				$requirements = 1 + max( array_keys( $args['data']['requirements'] ) );
218
+			if (isset($args['data']['requirements'])) {
219
+				$requirements = 1 + max(array_keys($args['data']['requirements']));
220 220
 
221
-				if ( $requirements > $arg_number ) {
221
+				if ($requirements > $arg_number) {
222 222
 					$arg_number = $requirements;
223 223
 				}
224 224
 			}
225 225
 
226
-			$this->action_index[ $method ]['actions'][ $slug ] = $args['data'];
226
+			$this->action_index[$method]['actions'][$slug] = $args['data'];
227 227
 		}
228 228
 
229
-		if ( isset( $args['arg_number'] ) ) {
229
+		if (isset($args['arg_number'])) {
230 230
 			$arg_number = $args['arg_number'];
231 231
 		}
232 232
 
233 233
 		// If this action is already being routed, and will have enough args, we
234 234
 		// don't need to hook to it again.
235 235
 		if (
236
-			isset( $this->action_index[ $method ]['arg_number'] )
237
-			&& $this->action_index[ $method ]['arg_number'] >= $arg_number
236
+			isset($this->action_index[$method]['arg_number'])
237
+			&& $this->action_index[$method]['arg_number'] >= $arg_number
238 238
 		) {
239 239
 			return;
240 240
 		}
241 241
 
242
-		$this->action_index[ $method ]['arg_number'] = $arg_number;
242
+		$this->action_index[$method]['arg_number'] = $arg_number;
243 243
 
244
-		add_action( $args['action'], array( $this, $method ), $priority, $arg_number );
244
+		add_action($args['action'], array($this, $method), $priority, $arg_number);
245 245
 	}
246 246
 
247 247
 	/**
@@ -251,20 +251,20 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @param string $slug The action slug.
253 253
 	 */
254
-	public function remove_action( $slug ) {
254
+	public function remove_action($slug) {
255 255
 
256
-		foreach ( $this->action_index as $method => $data ) {
257
-			if ( isset( $data['actions'][ $slug ] ) ) {
256
+		foreach ($this->action_index as $method => $data) {
257
+			if (isset($data['actions'][$slug])) {
258 258
 
259
-				unset( $this->action_index[ $method ]['actions'][ $slug ] );
259
+				unset($this->action_index[$method]['actions'][$slug]);
260 260
 
261
-				if ( empty( $this->action_index[ $method ]['actions'] ) ) {
261
+				if (empty($this->action_index[$method]['actions'])) {
262 262
 
263
-					unset( $this->action_index[ $method ] );
263
+					unset($this->action_index[$method]);
264 264
 
265
-					list( $action, $priority ) = explode( ',', $method );
265
+					list($action, $priority) = explode(',', $method);
266 266
 
267
-					remove_action( $action, array( $this, $method ), $priority );
267
+					remove_action($action, array($this, $method), $priority);
268 268
 				}
269 269
 			}
270 270
 		}
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @param string $action_slug The slug of the action.
280 280
 	 * @param string $action_type The type of action. Default is 'fire'.
281 281
 	 */
282
-	public function add_event_to_action( $event_slug, $action_slug, $action_type = 'fire' ) {
283
-		$this->event_index[ $action_slug ][ $action_type ][ $event_slug ] = true;
282
+	public function add_event_to_action($event_slug, $action_slug, $action_type = 'fire') {
283
+		$this->event_index[$action_slug][$action_type][$event_slug] = true;
284 284
 	}
285 285
 
286 286
 	/**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param string $action_slug The slug of the action.
293 293
 	 * @param string $action_type The type of action. Default is 'fire'.
294 294
 	 */
295
-	public function remove_event_from_action( $event_slug, $action_slug, $action_type = 'fire' ) {
296
-		unset( $this->event_index[ $action_slug ][ $action_type ][ $event_slug ] );
295
+	public function remove_event_from_action($event_slug, $action_slug, $action_type = 'fire') {
296
+		unset($this->event_index[$action_slug][$action_type][$event_slug]);
297 297
 	}
298 298
 
299 299
 	/**
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 	 */
306 306
 	public function get_event_index() {
307 307
 
308
-		if ( empty( $this->event_index ) ) {
309
-			wordpoints_hooks()->get_sub_app( 'events' );
308
+		if (empty($this->event_index)) {
309
+			wordpoints_hooks()->get_sub_app('events');
310 310
 		}
311 311
 
312 312
 		return $this->event_index;
Please login to merge, or discard this patch.
src/includes/classes/hook/extension/conditions.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @since 1.0.0
35 35
 	 */
36 36
 	public function __construct() {
37
-		$this->conditions = wordpoints_hooks()->get_sub_app( 'conditions' );
37
+		$this->conditions = wordpoints_hooks()->get_sub_app('conditions');
38 38
 	}
39 39
 
40 40
 	/**
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
 
45 45
 		$conditions_data = array();
46 46
 
47
-		foreach ( $this->conditions->get_all() as $data_type => $conditions ) {
48
-			foreach ( $conditions as $slug => $condition ) {
47
+		foreach ($this->conditions->get_all() as $data_type => $conditions) {
48
+			foreach ($conditions as $slug => $condition) {
49 49
 
50
-				if ( ! ( $condition instanceof WordPoints_Hook_ConditionI ) ) {
50
+				if ( ! ($condition instanceof WordPoints_Hook_ConditionI)) {
51 51
 					continue;
52 52
 				}
53 53
 
54
-				$conditions_data[ $data_type ][ $slug ] = array(
54
+				$conditions_data[$data_type][$slug] = array(
55 55
 					'slug'      => $slug,
56 56
 					'data_type' => $data_type,
57 57
 					'title'     => $condition->get_title(),
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 			}
61 61
 		}
62 62
 
63
-		return array( 'conditions' => $conditions_data );
63
+		return array('conditions' => $conditions_data);
64 64
 	}
65 65
 
66 66
 	/**
67 67
 	 * @since 1.0.0
68 68
 	 */
69
-	protected function validate_action_type_settings( $settings ) {
70
-		return $this->validate_conditions( $settings );
69
+	protected function validate_action_type_settings($settings) {
70
+		return $this->validate_conditions($settings);
71 71
 	}
72 72
 
73 73
 	/**
@@ -80,36 +80,36 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return array The validated settings.
82 82
 	 */
83
-	public function validate_conditions( $conditions, WordPoints_Hook_Event_Args $event_args = null ) {
83
+	public function validate_conditions($conditions, WordPoints_Hook_Event_Args $event_args = null) {
84 84
 
85
-		if ( $event_args ) {
85
+		if ($event_args) {
86 86
 			$this->event_args = $event_args;
87 87
 			$this->validator = $event_args->get_validator();
88 88
 		}
89 89
 
90
-		if ( ! is_array( $conditions ) ) {
90
+		if ( ! is_array($conditions)) {
91 91
 
92 92
 			$this->validator->add_error(
93
-				__( 'Conditions do not match expected format.', 'wordpoints' )
93
+				__('Conditions do not match expected format.', 'wordpoints')
94 94
 			);
95 95
 
96 96
 			return array();
97 97
 		}
98 98
 
99
-		foreach ( $conditions as $arg_slug => $sub_args ) {
99
+		foreach ($conditions as $arg_slug => $sub_args) {
100 100
 
101
-			if ( '_conditions' === $arg_slug ) {
101
+			if ('_conditions' === $arg_slug) {
102 102
 
103
-				$this->validator->push_field( $arg_slug );
103
+				$this->validator->push_field($arg_slug);
104 104
 
105
-				foreach ( $sub_args as $index => $settings ) {
105
+				foreach ($sub_args as $index => $settings) {
106 106
 
107
-					$this->validator->push_field( $index );
107
+					$this->validator->push_field($index);
108 108
 
109
-					$condition = $this->validate_condition( $settings );
109
+					$condition = $this->validate_condition($settings);
110 110
 
111
-					if ( $condition ) {
112
-						$sub_args[ $index ] = $condition;
111
+					if ($condition) {
112
+						$sub_args[$index] = $condition;
113 113
 					}
114 114
 
115 115
 					$this->validator->pop_field();
@@ -119,18 +119,18 @@  discard block
 block discarded – undo
119 119
 
120 120
 			} else {
121 121
 
122
-				if ( ! $this->event_args->descend( $arg_slug ) ) {
122
+				if ( ! $this->event_args->descend($arg_slug)) {
123 123
 					continue;
124 124
 				}
125 125
 
126
-				$sub_args = $this->validate_action_type_settings( $sub_args );
126
+				$sub_args = $this->validate_action_type_settings($sub_args);
127 127
 
128
-				$conditions[ $arg_slug ] = $sub_args;
128
+				$conditions[$arg_slug] = $sub_args;
129 129
 
130 130
 				$this->event_args->ascend();
131 131
 			}
132 132
 
133
-			$conditions[ $arg_slug ] = $sub_args;
133
+			$conditions[$arg_slug] = $sub_args;
134 134
 		}
135 135
 
136 136
 		return $conditions;
@@ -146,32 +146,32 @@  discard block
 block discarded – undo
146 146
 	 * @return array|false The validated conditions settings, or false if unable to
147 147
 	 *                     validate.
148 148
 	 */
149
-	protected function validate_condition( $settings ) {
149
+	protected function validate_condition($settings) {
150 150
 
151
-		if ( ! isset( $settings['type'] ) ) {
152
-			$this->validator->add_error( __( 'Condition type is missing.', 'wordpoints' ) );
151
+		if ( ! isset($settings['type'])) {
152
+			$this->validator->add_error(__('Condition type is missing.', 'wordpoints'));
153 153
 			return false;
154 154
 		}
155 155
 
156 156
 		$arg = $this->event_args->get_current();
157 157
 
158
-		$data_type = $this->get_data_type( $arg );
158
+		$data_type = $this->get_data_type($arg);
159 159
 
160
-		if ( ! $data_type ) {
160
+		if ( ! $data_type) {
161 161
 			$this->validator->add_error(
162
-				__( 'This type of condition does not work for the selected attribute.', 'wordpoints' )
162
+				__('This type of condition does not work for the selected attribute.', 'wordpoints')
163 163
 			);
164 164
 
165 165
 			return false;
166 166
 		}
167 167
 
168
-		$condition = $this->conditions->get( $data_type, $settings['type'] );
168
+		$condition = $this->conditions->get($data_type, $settings['type']);
169 169
 
170
-		if ( ! $condition ) {
170
+		if ( ! $condition) {
171 171
 
172 172
 			$this->validator->add_error(
173 173
 				sprintf(
174
-					__( 'Unknown condition type &#8220;%s&#8221;.', 'wordpoints' )
174
+					__('Unknown condition type &#8220;%s&#8221;.', 'wordpoints')
175 175
 					, $settings['type']
176 176
 				)
177 177
 				, 'type'
@@ -180,17 +180,17 @@  discard block
 block discarded – undo
180 180
 			return false;
181 181
 		}
182 182
 
183
-		if ( ! isset( $settings['settings'] ) ) {
184
-			$this->validator->add_error( __( 'Condition settings are missing.', 'wordpoints' ) );
183
+		if ( ! isset($settings['settings'])) {
184
+			$this->validator->add_error(__('Condition settings are missing.', 'wordpoints'));
185 185
 			return false;
186 186
 		}
187 187
 
188
-		$this->validator->push_field( 'settings' );
188
+		$this->validator->push_field('settings');
189 189
 
190 190
 		// The condition may call this object's validate_settings() method to
191 191
 		// validate some sub-conditions. When that happens, these properties will be
192 192
 		// reset, so we need to back up their values and then restore them below.
193
-		$backup = array( $this->validator, $this->event_args );
193
+		$backup = array($this->validator, $this->event_args);
194 194
 
195 195
 		$settings['settings'] = $condition->validate_settings(
196 196
 			$arg
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 			, $this->validator
199 199
 		);
200 200
 
201
-		list( $this->validator, $this->event_args ) = $backup;
201
+		list($this->validator, $this->event_args) = $backup;
202 202
 
203 203
 		$this->validator->pop_field();
204 204
 
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
 	/**
209 209
 	 * @since 1.0.0
210 210
 	 */
211
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
211
+	public function should_hit(WordPoints_Hook_Fire $fire) {
212 212
 
213
-		$conditions = $this->get_settings_from_fire( $fire );
213
+		$conditions = $this->get_settings_from_fire($fire);
214 214
 
215
-		if ( $conditions && ! $this->conditions_are_met( $conditions, $fire->event_args ) ) {
215
+		if ($conditions && ! $this->conditions_are_met($conditions, $fire->event_args)) {
216 216
 			return false;
217 217
 		}
218 218
 
@@ -234,35 +234,35 @@  discard block
 block discarded – undo
234 234
 		WordPoints_Hook_Event_Args $event_args
235 235
 	) {
236 236
 
237
-		foreach ( $conditions as $arg_slug => $sub_args ) {
237
+		foreach ($conditions as $arg_slug => $sub_args) {
238 238
 
239
-			$event_args->descend( $arg_slug );
239
+			$event_args->descend($arg_slug);
240 240
 
241
-			if ( isset( $sub_args['_conditions'] ) ) {
241
+			if (isset($sub_args['_conditions'])) {
242 242
 
243
-				foreach ( $sub_args['_conditions'] as $settings ) {
243
+				foreach ($sub_args['_conditions'] as $settings) {
244 244
 
245 245
 					$condition = $this->conditions->get(
246
-						$this->get_data_type( $event_args->get_current() )
246
+						$this->get_data_type($event_args->get_current())
247 247
 						, $settings['type']
248 248
 					);
249 249
 
250
-					$is_met = $condition->is_met( $settings['settings'], $event_args );
250
+					$is_met = $condition->is_met($settings['settings'], $event_args);
251 251
 
252
-					if ( ! $is_met ) {
252
+					if ( ! $is_met) {
253 253
 						$event_args->ascend();
254 254
 						return false;
255 255
 					}
256 256
 				}
257 257
 
258
-				unset( $sub_args['_conditions'] );
258
+				unset($sub_args['_conditions']);
259 259
 			}
260 260
 
261
-			$are_met = $this->conditions_are_met( $sub_args, $event_args );
261
+			$are_met = $this->conditions_are_met($sub_args, $event_args);
262 262
 
263 263
 			$event_args->ascend();
264 264
 
265
-			if ( ! $are_met ) {
265
+			if ( ! $are_met) {
266 266
 				return false;
267 267
 			}
268 268
 		}
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return string|false The data type, or false.
281 281
 	 */
282
-	protected function get_data_type( $arg ) {
282
+	protected function get_data_type($arg) {
283 283
 
284
-		if ( $arg instanceof WordPoints_Entity_Attr ) {
284
+		if ($arg instanceof WordPoints_Entity_Attr) {
285 285
 			$data_type = $arg->get_data_type();
286
-		} elseif ( $arg instanceof WordPoints_Entity_Array ) {
286
+		} elseif ($arg instanceof WordPoints_Entity_Array) {
287 287
 			$data_type = 'entity_array';
288
-		} elseif ( $arg instanceof WordPoints_Entity ) {
288
+		} elseif ($arg instanceof WordPoints_Entity) {
289 289
 			$data_type = 'entity';
290 290
 		} else {
291 291
 			$data_type = false;
Please login to merge, or discard this patch.
src/includes/classes/hook/reactor/points.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @since 1.0.0
29 29
 	 */
30
-	protected $action_types = array( 'fire', 'toggle_on', 'toggle_off' );
30
+	protected $action_types = array('fire', 'toggle_on', 'toggle_off');
31 31
 
32 32
 	/**
33 33
 	 * @since 1.0.0
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function get_settings_fields() {
60 60
 
61
-		$this->settings_fields['points']['label'] = _x( 'Points', 'form label', 'wordpoints' );
62
-		$this->settings_fields['log_text']['label'] = _x( 'Log Text', 'form label', 'wordpoints' );
63
-		$this->settings_fields['description']['label'] = _x( 'Description', 'form label', 'wordpoints' );
61
+		$this->settings_fields['points']['label'] = _x('Points', 'form label', 'wordpoints');
62
+		$this->settings_fields['log_text']['label'] = _x('Log Text', 'form label', 'wordpoints');
63
+		$this->settings_fields['description']['label'] = _x('Description', 'form label', 'wordpoints');
64 64
 
65 65
 		return parent::get_settings_fields();
66 66
 	}
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 
73 73
 		$data = parent::get_ui_script_data();
74 74
 
75
-		$data['target_label'] = __( 'Award To', 'wordpoints' );
76
-		$data['periods_label'] = __( 'Award each user no more than once per:', 'wordpoints' );
75
+		$data['target_label'] = __('Award To', 'wordpoints');
76
+		$data['periods_label'] = __('Award each user no more than once per:', 'wordpoints');
77 77
 
78 78
 		return $data;
79 79
 	}
@@ -87,23 +87,23 @@  discard block
 block discarded – undo
87 87
 		WordPoints_Hook_Event_Args $event_args
88 88
 	) {
89 89
 
90
-		if ( ! isset( $settings['points'] ) || false === wordpoints_int( $settings['points'] ) ) {
91
-			$validator->add_error( __( 'Points must be an integer.', 'wordpoints' ), 'points' );
90
+		if ( ! isset($settings['points']) || false === wordpoints_int($settings['points'])) {
91
+			$validator->add_error(__('Points must be an integer.', 'wordpoints'), 'points');
92 92
 		}
93 93
 
94
-		if ( ! isset( $settings['points_type'] ) || ! wordpoints_is_points_type( $settings['points_type'] ) ) {
95
-			$validator->add_error( __( 'Invalid points type.', 'wordpoints' ), 'points_type' );
94
+		if ( ! isset($settings['points_type']) || ! wordpoints_is_points_type($settings['points_type'])) {
95
+			$validator->add_error(__('Invalid points type.', 'wordpoints'), 'points_type');
96 96
 		}
97 97
 
98
-		if ( ! isset( $settings['description'] ) ) {
99
-			$validator->add_error( __( 'Description is required.', 'wordpoints' ), 'description' );
98
+		if ( ! isset($settings['description'])) {
99
+			$validator->add_error(__('Description is required.', 'wordpoints'), 'description');
100 100
 		}
101 101
 
102
-		if ( ! isset( $settings['log_text'] ) ) {
103
-			$validator->add_error( __( 'Log Text is required.', 'wordpoints' ), 'log_text' );
102
+		if ( ! isset($settings['log_text'])) {
103
+			$validator->add_error(__('Log Text is required.', 'wordpoints'), 'log_text');
104 104
 		}
105 105
 
106
-		return parent::validate_settings( $settings, $validator, $event_args );
106
+		return parent::validate_settings($settings, $validator, $event_args);
107 107
 	}
108 108
 
109 109
 	/**
@@ -114,58 +114,58 @@  discard block
 block discarded – undo
114 114
 		array $settings
115 115
 	) {
116 116
 
117
-		parent::update_settings( $reaction, $settings );
117
+		parent::update_settings($reaction, $settings);
118 118
 
119
-		$reaction->update_meta( 'points', $settings['points'] );
120
-		$reaction->update_meta( 'points_type', $settings['points_type'] );
121
-		$reaction->update_meta( 'description', $settings['description'] );
122
-		$reaction->update_meta( 'log_text', $settings['log_text'] );
119
+		$reaction->update_meta('points', $settings['points']);
120
+		$reaction->update_meta('points_type', $settings['points_type']);
121
+		$reaction->update_meta('description', $settings['description']);
122
+		$reaction->update_meta('log_text', $settings['log_text']);
123 123
 	}
124 124
 
125 125
 	/**
126 126
 	 * @since 1.0.0
127 127
 	 */
128
-	public function hit( WordPoints_Hook_Fire $fire ) {
128
+	public function hit(WordPoints_Hook_Fire $fire) {
129 129
 
130
-		if ( 'toggle_off' === $fire->action_type ) {
131
-			$this->reverse_hit( $fire );
130
+		if ('toggle_off' === $fire->action_type) {
131
+			$this->reverse_hit($fire);
132 132
 			return;
133 133
 		}
134 134
 
135 135
 		$reaction = $fire->reaction;
136 136
 
137 137
 		$target = $fire->event_args->get_from_hierarchy(
138
-			$reaction->get_meta( 'target' )
138
+			$reaction->get_meta('target')
139 139
 		);
140 140
 
141
-		if ( ! $target instanceof WordPoints_Entity ) {
141
+		if ( ! $target instanceof WordPoints_Entity) {
142 142
 			return;
143 143
 		}
144 144
 
145
-		$meta = array( 'hook_hit_id' => $fire->hit_id );
145
+		$meta = array('hook_hit_id' => $fire->hit_id);
146 146
 
147
-		foreach ( $fire->event_args->get_entities() as $entity ) {
148
-			$meta[ $entity->get_slug() ] = $entity->get_the_id();
147
+		foreach ($fire->event_args->get_entities() as $entity) {
148
+			$meta[$entity->get_slug()] = $entity->get_the_id();
149 149
 		}
150 150
 
151 151
 		wordpoints_alter_points(
152 152
 			$target->get_the_id()
153
-			, $reaction->get_meta( 'points' )
154
-			, $reaction->get_meta( 'points_type' )
153
+			, $reaction->get_meta('points')
154
+			, $reaction->get_meta('points_type')
155 155
 			, $reaction->get_event_slug()
156 156
 			, $meta
157
-			, $reaction->get_meta( 'log_text' )
157
+			, $reaction->get_meta('log_text')
158 158
 		);
159 159
 	}
160 160
 
161 161
 	/**
162 162
 	 * @since 1.0.0
163 163
 	 */
164
-	public function reverse_hit( WordPoints_Hook_Fire $fire ) {
164
+	public function reverse_hit(WordPoints_Hook_Fire $fire) {
165 165
 
166
-		$hit_ids = $this->get_hit_ids_to_be_reversed( $fire );
166
+		$hit_ids = $this->get_hit_ids_to_be_reversed($fire);
167 167
 
168
-		if ( empty( $hit_ids ) ) {
168
+		if (empty($hit_ids)) {
169 169
 			return;
170 170
 		}
171 171
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$logs = $query->get();
185 185
 
186
-		if ( ! $logs ) {
186
+		if ( ! $logs) {
187 187
 			return;
188 188
 		}
189 189
 
190
-		$this->reverse_logs( $logs, $fire );
190
+		$this->reverse_logs($logs, $fire);
191 191
 	}
192 192
 
193 193
 	/**
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return array The IDs of the hits to be reversed.
201 201
 	 */
202
-	protected function get_hit_ids_to_be_reversed( WordPoints_Hook_Fire $fire ) {
202
+	protected function get_hit_ids_to_be_reversed(WordPoints_Hook_Fire $fire) {
203 203
 
204 204
 		// We closely integrate with the reversals extension to get the hit IDs.
205
-		if ( ! isset( $fire->data['reversals']['hit_ids'] ) ) {
205
+		if ( ! isset($fire->data['reversals']['hit_ids'])) {
206 206
 			return array();
207 207
 		}
208 208
 
@@ -217,28 +217,28 @@  discard block
 block discarded – undo
217 217
 	 * @param object[]             $logs The logs to reverse.
218 218
 	 * @param WordPoints_Hook_Fire $fire The fire object.
219 219
 	 */
220
-	protected function reverse_logs( $logs, WordPoints_Hook_Fire $fire ) {
220
+	protected function reverse_logs($logs, WordPoints_Hook_Fire $fire) {
221 221
 
222
-		$event = wordpoints_hooks()->get_sub_app( 'events' )->get(
222
+		$event = wordpoints_hooks()->get_sub_app('events')->get(
223 223
 			$fire->reaction->get_event_slug()
224 224
 		);
225 225
 
226
-		if ( $event instanceof WordPoints_Hook_Event_ReversingI ) {
226
+		if ($event instanceof WordPoints_Hook_Event_ReversingI) {
227 227
 
228 228
 			/* translators: 1: log text for transaction that is being reversed, 2: the reason that this is being reversed. */
229
-			$template = __( 'Reversed &#8220;%1$s&#8221; (%2$s)', 'wordpoints' );
229
+			$template = __('Reversed &#8220;%1$s&#8221; (%2$s)', 'wordpoints');
230 230
 
231 231
 			$event_description = $event->get_reversal_text();
232 232
 
233 233
 		} else {
234 234
 
235 235
 			/* translators: 1: log text for transaction that is being reversed. */
236
-			$template = __( 'Reversed &#8220;%1$s&#8221;', 'wordpoints' );
236
+			$template = __('Reversed &#8220;%1$s&#8221;', 'wordpoints');
237 237
 
238 238
 			$event_description = '';
239 239
 		}
240 240
 
241
-		foreach ( $logs as $log ) {
241
+		foreach ($logs as $log) {
242 242
 
243 243
 			$log_id = wordpoints_alter_points(
244 244
 				$log->user_id
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
 					'original_log_id' => $log->id,
250 250
 					'hook_hit_id'     => $fire->hit_id,
251 251
 				)
252
-				, sprintf( $template, $log->text, $event_description )
252
+				, sprintf($template, $log->text, $event_description)
253 253
 			);
254 254
 
255 255
 			// Mark the old log as reversed by this one.
256
-			wordpoints_update_points_log_meta( $log->id, 'auto_reversed', $log_id );
256
+			wordpoints_update_points_log_meta($log->id, 'auto_reversed', $log_id);
257 257
 		}
258 258
 	}
259 259
 }
Please login to merge, or discard this patch.