Completed
Push — master ( 975fd1...3e68e7 )
by J.D.
03:16
created
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 “%s”.', 'wordpoints' )
174
+					__('Unknown condition type “%s”.', '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 “%1$s” (%2$s)', 'wordpoints' );
229
+			$template = __('Reversed “%1$s” (%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 “%1$s”', 'wordpoints' );
236
+			$template = __('Reversed “%1$s”', '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.
src/includes/classes/hook/actions.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function __construct() {
30 30
 
31
-		$this->router = wordpoints_hooks()->get_sub_app( 'router' );
31
+		$this->router = wordpoints_hooks()->get_sub_app('router');
32 32
 	}
33 33
 
34 34
 	/**
@@ -40,23 +40,23 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return object|false The action object, or false if not found.
42 42
 	 */
43
-	public function get( $slug, array $action_args = array(), array $args = array() ) {
43
+	public function get($slug, array $action_args = array(), array $args = array()) {
44 44
 
45
-		if ( ! isset( $this->classes[ $slug ] ) ) {
45
+		if ( ! isset($this->classes[$slug])) {
46 46
 			return false;
47 47
 		}
48 48
 
49
-		return new $this->classes[ $slug ]( $slug, $action_args, $args );
49
+		return new $this->classes[$slug]($slug, $action_args, $args);
50 50
 	}
51 51
 
52 52
 	/**
53 53
 	 * @since 1.0.0
54 54
 	 */
55
-	public function register( $slug, $class, array $args = array() ) {
55
+	public function register($slug, $class, array $args = array()) {
56 56
 
57
-		parent::register( $slug, $class, $args );
57
+		parent::register($slug, $class, $args);
58 58
 
59
-		$this->router->add_action( $slug, $args );
59
+		$this->router->add_action($slug, $args);
60 60
 
61 61
 		return true;
62 62
 	}
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 	/**
65 65
 	 * @since 1.0.0
66 66
 	 */
67
-	public function deregister( $slug ) {
67
+	public function deregister($slug) {
68 68
 
69
-		parent::deregister( $slug );
69
+		parent::deregister($slug);
70 70
 
71
-		$this->router->remove_action( $slug );
71
+		$this->router->remove_action($slug);
72 72
 	}
73 73
 }
74 74
 
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction/validator.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
 	 * @param bool                            $fail_fast Whether to fail as soon as
104 104
 	 *                                                   the first error is found.
105 105
 	 */
106
-	public function __construct( $settings, $fail_fast = false ) {
106
+	public function __construct($settings, $fail_fast = false) {
107 107
 
108 108
 		$this->fail_fast = $fail_fast;
109 109
 		$this->hooks = wordpoints_hooks();
110 110
 
111
-		if ( $settings instanceof WordPoints_Hook_ReactionI ) {
111
+		if ($settings instanceof WordPoints_Hook_ReactionI) {
112 112
 
113 113
 			$this->reaction     = $settings;
114 114
 			$this->settings     = $this->reaction->get_all_meta();
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 
120 120
 			$this->settings = $settings;
121 121
 
122
-			if ( isset( $this->settings['event'] ) ) {
122
+			if (isset($this->settings['event'])) {
123 123
 				$this->event_slug = $this->settings['event'];
124 124
 			}
125 125
 
126
-			if ( isset( $this->settings['reactor'] ) ) {
126
+			if (isset($this->settings['reactor'])) {
127 127
 				$this->reactor_slug = $this->settings['reactor'];
128 128
 			}
129 129
 		}
@@ -146,40 +146,40 @@  discard block
 block discarded – undo
146 146
 			$fail_fast = $this->fail_fast;
147 147
 			$this->fail_fast = true;
148 148
 
149
-			$events = $this->hooks->get_sub_app( 'events' );
149
+			$events = $this->hooks->get_sub_app('events');
150 150
 
151
-			if ( ! isset( $this->event_slug ) ) {
152
-				$this->add_error( __( 'Event is missing.', 'wordpoints' ), 'event' );
153
-			} elseif ( ! $events->is_registered( $this->event_slug ) ) {
154
-				$this->add_error( __( 'Event is invalid.', 'wordpoints' ), 'event' );
151
+			if ( ! isset($this->event_slug)) {
152
+				$this->add_error(__('Event is missing.', 'wordpoints'), 'event');
153
+			} elseif ( ! $events->is_registered($this->event_slug)) {
154
+				$this->add_error(__('Event is invalid.', 'wordpoints'), 'event');
155 155
 			}
156 156
 
157
-			$reactors = $this->hooks->get_sub_app( 'reactors' );
157
+			$reactors = $this->hooks->get_sub_app('reactors');
158 158
 
159
-			if ( ! isset( $this->reactor_slug ) ) {
160
-				$this->add_error( __( 'Reactor is missing.', 'wordpoints' ), 'reactor' );
161
-			} elseif ( ! $reactors->is_registered( $this->reactor_slug ) ) {
162
-				$this->add_error( __( 'Reactor is invalid.', 'wordpoints' ), 'reactor' );
159
+			if ( ! isset($this->reactor_slug)) {
160
+				$this->add_error(__('Reactor is missing.', 'wordpoints'), 'reactor');
161
+			} elseif ( ! $reactors->is_registered($this->reactor_slug)) {
162
+				$this->add_error(__('Reactor is invalid.', 'wordpoints'), 'reactor');
163 163
 			}
164 164
 
165 165
 			// From here on out we can collect errors as they come (unless we are
166 166
 			// supposed to fail fast).
167 167
 			$this->fail_fast = $fail_fast;
168 168
 
169
-			$event_args = $events->get_sub_app( 'args' )->get_children(
169
+			$event_args = $events->get_sub_app('args')->get_children(
170 170
 				$this->event_slug
171 171
 			);
172 172
 
173
-			$this->event_args = new WordPoints_Hook_Event_Args( $event_args );
174
-			$this->event_args->set_validator( $this );
173
+			$this->event_args = new WordPoints_Hook_Event_Args($event_args);
174
+			$this->event_args->set_validator($this);
175 175
 
176
-			$reactor = $reactors->get( $this->reactor_slug );
176
+			$reactor = $reactors->get($this->reactor_slug);
177 177
 
178
-			$this->settings = $reactor->validate_settings( $this->settings, $this, $this->event_args );
178
+			$this->settings = $reactor->validate_settings($this->settings, $this, $this->event_args);
179 179
 
180 180
 			/** @var WordPoints_Hook_ExtensionI $extension */
181
-			foreach ( $this->hooks->get_sub_app( 'extensions' )->get_all() as $extension ) {
182
-				$this->settings = $extension->validate_settings( $this->settings, $this, $this->event_args );
181
+			foreach ($this->hooks->get_sub_app('extensions')->get_all() as $extension) {
182
+				$this->settings = $extension->validate_settings($this->settings, $this, $this->event_args);
183 183
 			}
184 184
 
185 185
 			/**
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
 			 * @param WordPoints_Hook_Reaction_Validator $validator The validator object.
190 190
 			 * @param WordPoints_Hook_Event_Args         $args      The event args object.
191 191
 			 */
192
-			$this->settings = apply_filters( 'wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args );
192
+			$this->settings = apply_filters('wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args);
193 193
 
194
-		} catch ( WordPoints_Hook_Validator_Exception $e ) {
194
+		} catch (WordPoints_Hook_Validator_Exception $e) {
195 195
 
196 196
 			// Do nothing.
197
-			unset( $e );
197
+			unset($e);
198 198
 		}
199 199
 
200 200
 		return $this->settings;
@@ -222,17 +222,17 @@  discard block
 block discarded – undo
222 222
 	 * @throws WordPoints_Hook_Validator_Exception If the validator is configured to
223 223
 	 *                                             fail as soon as an error is found.
224 224
 	 */
225
-	public function add_error( $message, $field = null ) {
225
+	public function add_error($message, $field = null) {
226 226
 
227 227
 		$field_stack = $this->field_stack;
228 228
 
229
-		if ( null !== $field ) {
229
+		if (null !== $field) {
230 230
 			$field_stack[] = $field;
231 231
 		}
232 232
 
233
-		$this->errors[] = array( 'message' => $message, 'field' => $field_stack );
233
+		$this->errors[] = array('message' => $message, 'field' => $field_stack);
234 234
 
235
-		if ( $this->fail_fast ) {
235
+		if ($this->fail_fast) {
236 236
 			throw new WordPoints_Hook_Validator_Exception;
237 237
 		}
238 238
 	}
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @return bool Whether the validator found any errors.
246 246
 	 */
247 247
 	public function had_errors() {
248
-		return ! empty( $this->errors );
248
+		return ! empty($this->errors);
249 249
 	}
250 250
 
251 251
 	/**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @param string $field The field.
268 268
 	 */
269
-	public function push_field( $field ) {
269
+	public function push_field($field) {
270 270
 		$this->field_stack[] = $field;
271 271
 	}
272 272
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * @since 1.0.0
277 277
 	 */
278 278
 	public function pop_field() {
279
-		array_pop( $this->field_stack );
279
+		array_pop($this->field_stack);
280 280
 	}
281 281
 
282 282
 	/**
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	 */
322 322
 	public function get_id() {
323 323
 
324
-		if ( ! $this->reaction ) {
324
+		if ( ! $this->reaction) {
325 325
 			return false;
326 326
 		}
327 327
 
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
 	 *
360 360
 	 * @return mixed The meta value.
361 361
 	 */
362
-	public function get_meta( $key ) {
362
+	public function get_meta($key) {
363 363
 
364
-		if ( ! isset( $this->settings[ $key ] ) ) {
364
+		if ( ! isset($this->settings[$key])) {
365 365
 			return null;
366 366
 		}
367 367
 
368
-		return $this->settings[ $key ];
368
+		return $this->settings[$key];
369 369
 	}
370 370
 
371 371
 	/**
Please login to merge, or discard this patch.
src/includes/classes/hook/condition.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,33 +23,33 @@  discard block
 block discarded – undo
23 23
 		WordPoints_Hook_Reaction_Validator $validator
24 24
 	) {
25 25
 
26
-		if ( ! isset( $settings['value'] ) || '' === $settings['value'] ) {
26
+		if ( ! isset($settings['value']) || '' === $settings['value']) {
27 27
 
28 28
 			$settings_fields = $this->get_settings_fields();
29 29
 
30 30
 			$validator->add_error(
31 31
 				sprintf(
32
-					__( '%s is required.', 'wordpoints' )
32
+					__('%s is required.', 'wordpoints')
33 33
 					, $settings_fields['value']['label']
34 34
 				)
35 35
 				, 'value'
36 36
 			);
37 37
 
38
-		} elseif ( $arg instanceof WordPoints_Entity_Attr ) {
38
+		} elseif ($arg instanceof WordPoints_Entity_Attr) {
39 39
 
40
-			$data_types = wordpoints_apps()->get_sub_app( 'data_types' );
40
+			$data_types = wordpoints_apps()->get_sub_app('data_types');
41 41
 
42
-			$data_type = $data_types->get( $arg->get_data_type() );
42
+			$data_type = $data_types->get($arg->get_data_type());
43 43
 
44 44
 			// If this data type isn't recognized, that's probably OK. Validation is
45 45
 			// just to help the user know that they've made a mistake anyway.
46
-			if ( ! ( $data_type instanceof WordPoints_Data_TypeI ) ) {
46
+			if ( ! ($data_type instanceof WordPoints_Data_TypeI)) {
47 47
 				return $settings;
48 48
 			}
49 49
 
50
-			$validated_value = $data_type->validate_value( $settings['value'] );
50
+			$validated_value = $data_type->validate_value($settings['value']);
51 51
 
52
-			if ( is_wp_error( $validated_value ) ) {
52
+			if (is_wp_error($validated_value)) {
53 53
 
54 54
 				$settings_fields = $this->get_settings_fields();
55 55
 
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 
67 67
 			$settings['value'] = $validated_value;
68 68
 
69
-		} elseif ( $arg instanceof WordPoints_Entity ) {
69
+		} elseif ($arg instanceof WordPoints_Entity) {
70 70
 
71
-			if ( ! $arg->exists( $settings['value'] ) ) {
71
+			if ( ! $arg->exists($settings['value'])) {
72 72
 				$validator->add_error(
73 73
 					sprintf(
74 74
 						// translators: 1. item type, 2. item ID/slug.
75
-						__( '%1$s “%2$s” not found.', 'wordpoints' )
75
+						__('%1$s “%2$s” not found.', 'wordpoints')
76 76
 						, $arg->get_title()
77 77
 						, $settings['value']
78 78
 					)
Please login to merge, or discard this patch.
src/includes/classes/hook/settings.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 interface WordPoints_Hook_Reaction_SettingI {
11
-	public function __construct( $slug );
11
+	public function __construct($slug);
12 12
 	public function get_type();
13 13
 	public function get_label();
14 14
 	public function is_required();
15
-	public function get( WordPoints_Hook_ReactionI $reaction );
16
-	public function validate( $value, WordPoints_Hook_Reaction_Validator $validator );
17
-	public function save( $value, WordPoints_Hook_ReactionI $reaction, $is_new );
15
+	public function get(WordPoints_Hook_ReactionI $reaction);
16
+	public function validate($value, WordPoints_Hook_Reaction_Validator $validator);
17
+	public function save($value, WordPoints_Hook_ReactionI $reaction, $is_new);
18 18
 }
19 19
 
20 20
 class WordPoints_Hook_Reaction_Setting implements WordPoints_Hook_Reaction_SettingI {
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	protected $type = 'hidden';
24 24
 	protected $required = true;
25 25
 
26
-	public function __construct( $slug ) {
26
+	public function __construct($slug) {
27 27
 		$this->slug = $slug;
28 28
 	}
29 29
 
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
 		return $this->required;
40 40
 	}
41 41
 
42
-	public function get( WordPoints_Hook_ReactionI $reaction ) {
43
-		return $reaction->get_meta( $this->slug );
42
+	public function get(WordPoints_Hook_ReactionI $reaction) {
43
+		return $reaction->get_meta($this->slug);
44 44
 	}
45 45
 
46
-	public function validate( $value, WordPoints_Hook_Reaction_Validator $validator ) {
46
+	public function validate($value, WordPoints_Hook_Reaction_Validator $validator) {
47 47
 
48
-		if ( $this->is_required() && '' === trim( $value ) ) {
48
+		if ($this->is_required() && '' === trim($value)) {
49 49
 
50 50
 			$validator->add_error(
51 51
 				sprintf(
52
-					__( '%s cannot be empty.', 'wordpoints' )
52
+					__('%s cannot be empty.', 'wordpoints')
53 53
 					, $this->get_label()
54 54
 				)
55 55
 				, $this->slug
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 		return $value;
60 60
 	}
61 61
 
62
-	public function save( $value, WordPoints_Hook_ReactionI $reaction, $is_new ) {
63
-		$reaction->update_meta( $this->slug, $value );
62
+	public function save($value, WordPoints_Hook_ReactionI $reaction, $is_new) {
63
+		$reaction->update_meta($this->slug, $value);
64 64
 	}
65 65
 }
66 66
 //
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 
83 83
 		$fields = array();
84 84
 
85
-		foreach ( $this->settings as $slug => $class ) {
85
+		foreach ($this->settings as $slug => $class) {
86 86
 
87 87
 			/** @var WordPoints_Hook_Reaction_SettingI $setting */
88
-			$setting = new $class( $slug );
88
+			$setting = new $class($slug);
89 89
 
90
-			$fields[ $slug ] = array(
90
+			$fields[$slug] = array(
91 91
 				'type' => $setting->get_type(),
92 92
 				'label' => $setting->get_label(),
93 93
 				'required' => $setting->is_required(),
@@ -97,29 +97,29 @@  discard block
 block discarded – undo
97 97
 		return $fields;
98 98
 	}
99 99
 
100
-	public function save_settings( $reaction, $settings, $is_new ) {
100
+	public function save_settings($reaction, $settings, $is_new) {
101 101
 
102
-		foreach ( $this->settings as $slug => $class ) {
102
+		foreach ($this->settings as $slug => $class) {
103 103
 
104 104
 			/** @var WordPoints_Hook_Reaction_SettingI $setting */
105
-			$setting = new $class( $slug );
105
+			$setting = new $class($slug);
106 106
 
107
-			$value = isset( $settings[ $slug ] ) ? $settings[ $slug ] : null;
107
+			$value = isset($settings[$slug]) ? $settings[$slug] : null;
108 108
 
109
-			$setting->save( $value, $reaction, $is_new );
109
+			$setting->save($value, $reaction, $is_new);
110 110
 		}
111 111
 	}
112 112
 
113
-	public function validate_settings( $settings, $validator ) {
113
+	public function validate_settings($settings, $validator) {
114 114
 
115
-		foreach ( $this->settings as $slug => $class ) {
115
+		foreach ($this->settings as $slug => $class) {
116 116
 
117 117
 			/** @var WordPoints_Hook_Reaction_SettingI $setting */
118
-			$setting = new $class( $slug );
118
+			$setting = new $class($slug);
119 119
 
120
-			$value = isset( $settings[ $slug ] ) ? $settings[ $slug ] : null;
120
+			$value = isset($settings[$slug]) ? $settings[$slug] : null;
121 121
 
122
-			$settings[ $slug ] = $setting->validate( $value, $validator );
122
+			$settings[$slug] = $setting->validate($value, $validator);
123 123
 		}
124 124
 
125 125
 		return $settings;
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
  *
134 134
  * @param WordPoints_Hooks $hooks
135 135
  */
136
-function wordpoints_hook_settings_app( $hooks ) {
137
-	$hooks->sub_apps()->register( 'settings', 'WordPoints_Hook_Settings' );
136
+function wordpoints_hook_settings_app($hooks) {
137
+	$hooks->sub_apps()->register('settings', 'WordPoints_Hook_Settings');
138 138
 }
139 139
 //add_action( 'wordpoints_hooks_init', 'wordpoints_hook_settings_app' );
140 140
 
@@ -145,12 +145,12 @@  discard block
 block discarded – undo
145 145
  *
146 146
  * @param WordPoints_Hook_Settings $settings
147 147
  */
148
-function wordpoints_register_hook_settings( $settings ) {
148
+function wordpoints_register_hook_settings($settings) {
149 149
 
150
-	add_action( 'wordpoints_hook_reaction_save', array( $settings, 'save_settings' ), 10, 3 );
151
-	add_filter( 'wordpoints_hook_reaction_validate', array( $settings, 'validate_settings' ), 10, 2 );
150
+	add_action('wordpoints_hook_reaction_save', array($settings, 'save_settings'), 10, 3);
151
+	add_filter('wordpoints_hook_reaction_validate', array($settings, 'validate_settings'), 10, 2);
152 152
 
153
-	$settings->register( 'description', 'WordPoints_Hook_Reaction_Setting_Description' );
153
+	$settings->register('description', 'WordPoints_Hook_Reaction_Setting_Description');
154 154
 }
155 155
 //add_action( 'wordpoints_hook_settings_init', 'wordpoints_register_hook_settings' );
156 156
 
Please login to merge, or discard this patch.
src/includes/classes/hook/condition/entity/array/contains.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function __construct() {
49 49
 
50
-		$this->conditions_extension = wordpoints_hooks()->get_sub_app( 'extensions' )->get(
50
+		$this->conditions_extension = wordpoints_hooks()->get_sub_app('extensions')->get(
51 51
 			'conditions'
52 52
 		);
53 53
 	}
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @since 1.0.0
57 57
 	 */
58 58
 	public function get_title() {
59
-		return __( 'Contains', 'wordpoints' );
59
+		return __('Contains', 'wordpoints');
60 60
 	}
61 61
 
62 62
 	/**
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 		return array(
67 67
 			'min' => array(
68 68
 				'slug'    => 'min',
69
-				'label'   => __( 'Minimum number of items', 'wordpoints' ),
69
+				'label'   => __('Minimum number of items', 'wordpoints'),
70 70
 				'type'    => 'number',
71 71
 				'default' => 1,
72 72
 			),
73 73
 			'max' => array(
74 74
 				'slug'  => 'max',
75
-				'label' => __( 'Maximum number of items', 'wordpoints' ),
75
+				'label' => __('Maximum number of items', 'wordpoints'),
76 76
 				'type'  => 'number',
77 77
 			),
78 78
 		);
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 
93 93
 		$this->validate_count();
94 94
 
95
-		if ( isset( $settings['conditions'] ) ) {
96
-			$this->validate_conditions( $arg );
95
+		if (isset($settings['conditions'])) {
96
+			$this->validate_conditions($arg);
97 97
 		}
98 98
 
99 99
 		return $this->settings;
@@ -107,31 +107,31 @@  discard block
 block discarded – undo
107 107
 	protected function validate_count() {
108 108
 
109 109
 		if (
110
-			! empty( $this->settings['max'] )
111
-			&& ! wordpoints_posint( $this->settings['max'] )
110
+			! empty($this->settings['max'])
111
+			&& ! wordpoints_posint($this->settings['max'])
112 112
 		) {
113 113
 			$this->validator->add_error(
114
-				__( 'The maximum must be a positive integer.', 'wordpoints' )
114
+				__('The maximum must be a positive integer.', 'wordpoints')
115 115
 				, 'max'
116 116
 			);
117 117
 		}
118 118
 
119
-		if ( ! empty( $this->settings['min'] ) ) {
119
+		if ( ! empty($this->settings['min'])) {
120 120
 
121
-			if ( ! wordpoints_posint( $this->settings['min'] ) ) {
121
+			if ( ! wordpoints_posint($this->settings['min'])) {
122 122
 
123 123
 				$this->validator->add_error(
124
-					__( 'The minimum must be a positive integer.', 'wordpoints' )
124
+					__('The minimum must be a positive integer.', 'wordpoints')
125 125
 					, 'min'
126 126
 				);
127 127
 
128 128
 			} elseif (
129
-				! empty( $this->settings['max'] )
129
+				! empty($this->settings['max'])
130 130
 				&& $this->settings['max'] < $this->settings['min']
131 131
 			) {
132 132
 
133 133
 				$this->validator->add_error(
134
-					__( 'The minimum must be less than the maximum.', 'wordpoints' )
134
+					__('The minimum must be less than the maximum.', 'wordpoints')
135 135
 					, 'min'
136 136
 				);
137 137
 			}
@@ -145,24 +145,24 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param WordPoints_EntityishI $current_arg The current arg.
147 147
 	 */
148
-	protected function validate_conditions( $current_arg ) {
148
+	protected function validate_conditions($current_arg) {
149 149
 
150
-		$args = new WordPoints_Hook_Event_Args( array() );
150
+		$args = new WordPoints_Hook_Event_Args(array());
151 151
 
152
-		if ( $current_arg instanceof WordPoints_Entity_Array ) {
152
+		if ($current_arg instanceof WordPoints_Entity_Array) {
153 153
 
154 154
 			$entity = wordpoints_entities()->get(
155 155
 				$current_arg->get_entity_slug()
156 156
 			);
157 157
 
158
-			if ( $entity instanceof WordPoints_Entity ) {
159
-				$args->add_entity( $entity );
158
+			if ($entity instanceof WordPoints_Entity) {
159
+				$args->add_entity($entity);
160 160
 			}
161 161
 		}
162 162
 
163
-		$args->set_validator( $this->validator );
163
+		$args->set_validator($this->validator);
164 164
 
165
-		$this->validator->push_field( 'conditions' );
165
+		$this->validator->push_field('conditions');
166 166
 
167 167
 		$this->settings['conditions'] = $this->conditions_extension->validate_conditions(
168 168
 			$this->settings['conditions']
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	/**
176 176
 	 * @since 1.0.0
177 177
 	 */
178
-	public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) {
178
+	public function is_met(array $settings, WordPoints_Hook_Event_Args $args) {
179 179
 
180 180
 		$this->settings = $settings;
181 181
 
@@ -183,16 +183,16 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$entities = array();
185 185
 
186
-		if ( $arg instanceof WordPoints_Entity_Array ) {
186
+		if ($arg instanceof WordPoints_Entity_Array) {
187 187
 
188 188
 			$entities = $arg->get_the_entities();
189 189
 
190
-			if ( isset( $this->settings['conditions'] ) ) {
191
-				$entities = $this->filter_entities( $entities );
190
+			if (isset($this->settings['conditions'])) {
191
+				$entities = $this->filter_entities($entities);
192 192
 			}
193 193
 		}
194 194
 
195
-		return $this->check_count( count( $entities ) );
195
+		return $this->check_count(count($entities));
196 196
 	}
197 197
 
198 198
 	/**
@@ -204,20 +204,20 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return WordPoints_Entity[] The entities that matched the sub-conditions.
206 206
 	 */
207
-	protected function filter_entities( $entities ) {
207
+	protected function filter_entities($entities) {
208 208
 
209
-		foreach ( $entities as $index => $entity ) {
209
+		foreach ($entities as $index => $entity) {
210 210
 
211
-			$event_args = new WordPoints_Hook_Event_Args( array() );
212
-			$event_args->add_entity( $entity );
211
+			$event_args = new WordPoints_Hook_Event_Args(array());
212
+			$event_args->add_entity($entity);
213 213
 
214 214
 			$matches = $this->conditions_extension->conditions_are_met(
215 215
 				$this->settings['conditions']
216 216
 				, $event_args
217 217
 			);
218 218
 
219
-			if ( ! $matches ) {
220
-				unset( $entities[ $index ] );
219
+			if ( ! $matches) {
220
+				unset($entities[$index]);
221 221
 			}
222 222
 		}
223 223
 
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @return bool Whether the count met the requirements.
235 235
 	 */
236
-	protected function check_count( $count ) {
236
+	protected function check_count($count) {
237 237
 
238
-		if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) {
238
+		if (isset($this->settings['max']) && $count > $this->settings['max']) {
239 239
 			return false;
240 240
 		}
241 241
 
242
-		if ( isset( $this->settings['min'] ) && $count < $this->settings['min'] ) {
242
+		if (isset($this->settings['min']) && $count < $this->settings['min']) {
243 243
 			return false;
244 244
 		}
245 245
 
Please login to merge, or discard this patch.
src/includes/classes/hook/events.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * @since 1.0.0
37 37
 	 */
38
-	public function __construct( $slug ) {
38
+	public function __construct($slug) {
39 39
 
40 40
 		$hooks = wordpoints_hooks();
41 41
 
42
-		$this->router = $hooks->get_sub_app( 'router' );
42
+		$this->router = $hooks->get_sub_app('router');
43 43
 
44
-		parent::__construct( $slug );
44
+		parent::__construct($slug);
45 45
 	}
46 46
 
47 47
 	/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function init() {
51 51
 
52
-		$this->sub_apps()->register( 'args', 'WordPoints_Class_Registry_Children' );
52
+		$this->sub_apps()->register('args', 'WordPoints_Class_Registry_Children');
53 53
 
54 54
 		parent::init();
55 55
 	}
@@ -73,27 +73,27 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return bool Whether the event was registered.
75 75
 	 */
76
-	public function register( $slug, $class, array $args = array() ) {
76
+	public function register($slug, $class, array $args = array()) {
77 77
 
78
-		parent::register( $slug, $class, $args );
78
+		parent::register($slug, $class, $args);
79 79
 
80
-		if ( isset( $args['actions'] ) ) {
81
-			foreach ( $args['actions'] as $type => $actions ) {
82
-				foreach ( (array) $actions as $action_slug ) {
83
-					$this->router->add_event_to_action( $slug, $action_slug, $type );
80
+		if (isset($args['actions'])) {
81
+			foreach ($args['actions'] as $type => $actions) {
82
+				foreach ((array) $actions as $action_slug) {
83
+					$this->router->add_event_to_action($slug, $action_slug, $type);
84 84
 				}
85 85
 			}
86 86
 		}
87 87
 
88
-		if ( isset( $args['args'] ) ) {
89
-			$args_registry = $this->get_sub_app( 'args' );
88
+		if (isset($args['args'])) {
89
+			$args_registry = $this->get_sub_app('args');
90 90
 
91
-			foreach ( $args['args'] as $arg_slug => $class ) {
92
-				$args_registry->register( $slug, $arg_slug, $class );
91
+			foreach ($args['args'] as $arg_slug => $class) {
92
+				$args_registry->register($slug, $arg_slug, $class);
93 93
 			}
94 94
 		}
95 95
 
96
-		$this->event_data[ $slug ] = $args;
96
+		$this->event_data[$slug] = $args;
97 97
 
98 98
 		return true;
99 99
 	}
@@ -101,23 +101,23 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * @since 1.0.0
103 103
 	 */
104
-	public function deregister( $slug ) {
104
+	public function deregister($slug) {
105 105
 
106
-		if ( ! $this->is_registered( $slug ) ) {
106
+		if ( ! $this->is_registered($slug)) {
107 107
 			return;
108 108
 		}
109 109
 
110
-		parent::deregister( $slug );
110
+		parent::deregister($slug);
111 111
 
112
-		foreach ( (array) $this->event_data[ $slug ]['actions'] as $type => $actions ) {
113
-			foreach ( (array) $actions as $action_slug ) {
114
-				$this->router->remove_event_from_action( $slug, $action_slug, $type );
112
+		foreach ((array) $this->event_data[$slug]['actions'] as $type => $actions) {
113
+			foreach ((array) $actions as $action_slug) {
114
+				$this->router->remove_event_from_action($slug, $action_slug, $type);
115 115
 			}
116 116
 		}
117 117
 
118
-		$this->get_sub_app( 'args' )->deregister_children( $slug );
118
+		$this->get_sub_app('args')->deregister_children($slug);
119 119
 
120
-		unset( $this->event_data[ $slug ] );
120
+		unset($this->event_data[$slug]);
121 121
 	}
122 122
 }
123 123
 
Please login to merge, or discard this patch.
src/includes/classes/entity.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return mixed The entity, or false if not found.
108 108
 	 */
109
-	protected function get_entity( $id ) {
109
+	protected function get_entity($id) {
110 110
 
111
-		$entity = call_user_func( $this->getter, $id );
111
+		$entity = call_user_func($this->getter, $id);
112 112
 
113
-		if ( ! $this->is_entity( $entity ) ) {
113
+		if ( ! $this->is_entity($entity)) {
114 114
 			return false;
115 115
 		}
116 116
 
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return bool Whether the passed value is an entity.
128 128
 	 */
129
-	protected function is_entity( $entity ) {
129
+	protected function is_entity($entity) {
130 130
 
131
-		if ( ! is_object( $entity ) && ! is_array( $entity ) ) {
131
+		if ( ! is_object($entity) && ! is_array($entity)) {
132 132
 			return false;
133 133
 		}
134 134
 
135
-		return (bool) $this->get_entity_id( $entity );
135
+		return (bool) $this->get_entity_id($entity);
136 136
 	}
137 137
 
138 138
 	/**
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @return mixed The value of the attribute of the entity.
147 147
 	 */
148
-	protected function get_attr_value( $entity, $attr ) {
148
+	protected function get_attr_value($entity, $attr) {
149 149
 
150
-		if ( is_array( $entity ) ) {
151
-			if ( isset( $entity[ $attr ] ) ) {
152
-				return $entity[ $attr ];
150
+		if (is_array($entity)) {
151
+			if (isset($entity[$attr])) {
152
+				return $entity[$attr];
153 153
 			}
154 154
 		} else {
155
-			if ( isset( $entity->{$attr} ) ) {
155
+			if (isset($entity->{$attr} )) {
156 156
 				return $entity->{$attr};
157 157
 			}
158 158
 		}
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @return mixed The ID of the entity.
171 171
 	 */
172
-	protected function get_entity_id( $entity ) {
173
-		return $this->get_attr_value( $entity, $this->get_id_field() );
172
+	protected function get_entity_id($entity) {
173
+		return $this->get_attr_value($entity, $this->get_id_field());
174 174
 	}
175 175
 
176 176
 	/**
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return mixed The human ID of the entity.
188 188
 	 */
189
-	protected function get_entity_human_id( $entity ) {
190
-		return $this->get_attr_value( $entity, $this->human_id_field );
189
+	protected function get_entity_human_id($entity) {
190
+		return $this->get_attr_value($entity, $this->human_id_field);
191 191
 	}
192 192
 
193 193
 	//
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return string|int|float|false The human identifier for the entity, or false.
231 231
 	 */
232
-	public function get_human_id( $id ) {
232
+	public function get_human_id($id) {
233 233
 
234
-		$entity = $this->get_entity( $id );
234
+		$entity = $this->get_entity($id);
235 235
 
236
-		if ( ! $entity ) {
236
+		if ( ! $entity) {
237 237
 			return false;
238 238
 		}
239 239
 
240
-		return $this->get_entity_human_id( $entity );
240
+		return $this->get_entity_human_id($entity);
241 241
 	}
242 242
 
243 243
 	/**
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 	 *
250 250
 	 * @return bool Whether or not an entity with that ID exists.
251 251
 	 */
252
-	public function exists( $id ) {
253
-		return (bool) $this->get_entity( $id );
252
+	public function exists($id) {
253
+		return (bool) $this->get_entity($id);
254 254
 	}
255 255
 
256 256
 	/**
@@ -265,17 +265,17 @@  discard block
 block discarded – undo
265 265
 	 *
266 266
 	 * @return WordPoints_Entityish|false The child's object, or false if not found.
267 267
 	 */
268
-	public function get_child( $child_slug ) {
268
+	public function get_child($child_slug) {
269 269
 
270
-		$children = wordpoints_entities()->get_sub_app( 'children' );
270
+		$children = wordpoints_entities()->get_sub_app('children');
271 271
 
272
-		$child = $children->get( $this->slug, $child_slug );
272
+		$child = $children->get($this->slug, $child_slug);
273 273
 
274 274
 		if (
275
-			isset( $this->the_value )
275
+			isset($this->the_value)
276 276
 			&& $child instanceof WordPoints_Entity_ChildI
277 277
 		) {
278
-			$child->set_the_value_from_entity( $this );
278
+			$child->set_the_value_from_entity($this);
279 279
 		}
280 280
 
281 281
 		return $child;
@@ -297,20 +297,20 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return bool Whether the value was set.
299 299
 	 */
300
-	public function set_the_value( $value ) {
300
+	public function set_the_value($value) {
301 301
 
302 302
 		$this->the_value = $this->the_entity = $this->the_context = null;
303 303
 
304
-		if ( $this->is_entity( $value ) ) {
304
+		if ($this->is_entity($value)) {
305 305
 
306 306
 			$entity = $value;
307
-			$value = $this->get_entity_id( $value );
307
+			$value = $this->get_entity_id($value);
308 308
 
309 309
 		} else {
310 310
 
311
-			$entity = $this->get_entity( $value );
311
+			$entity = $this->get_entity($value);
312 312
 
313
-			if ( ! $entity ) {
313
+			if ( ! $entity) {
314 314
 				return false;
315 315
 			}
316 316
 		}
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 	 *
334 334
 	 * @return mixed The value of the attribute.
335 335
 	 */
336
-	public function get_the_attr_value( $attr ) {
337
-		return $this->get_attr_value( $this->the_entity, $attr );
336
+	public function get_the_attr_value($attr) {
337
+		return $this->get_attr_value($this->the_entity, $attr);
338 338
 	}
339 339
 
340 340
 	/**
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	 * @return string|int|float|null The human identifier for the entity, or null.
359 359
 	 */
360 360
 	public function get_the_human_id() {
361
-		return $this->get_entity_human_id( $this->the_entity );
361
+		return $this->get_entity_human_id($this->the_entity);
362 362
 	}
363 363
 
364 364
 	/**
@@ -392,11 +392,11 @@  discard block
 block discarded – undo
392 392
 
393 393
 		$guid = $this->get_the_context();
394 394
 
395
-		if ( ! is_array( $guid ) ) {
395
+		if ( ! is_array($guid)) {
396 396
 			return $guid;
397 397
 		}
398 398
 
399
-		$guid = array( $this->slug => $this->get_the_id() ) + $guid;
399
+		$guid = array($this->slug => $this->get_the_id()) + $guid;
400 400
 
401 401
 		return $guid;
402 402
 	}
Please login to merge, or discard this patch.