Completed
Push — master ( 5b2818...3f335f )
by J.D.
03:35
created
src/includes/classes/hook/reactioni.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @return bool Whether the event was updated successfully.
59 59
 	 */
60
-	public function update_event_slug( $event_slug );
60
+	public function update_event_slug($event_slug);
61 61
 
62 62
 	/**
63 63
 	 * Get the slug of the reactor this reaction is for.
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return mixed|false The meta value, or false if not found.
92 92
 	 */
93
-	public function get_meta( $key );
93
+	public function get_meta($key);
94 94
 
95 95
 	/**
96 96
 	 * Add a piece of metadata for this reaction.
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @return bool Whether the metadata was added successfully.
106 106
 	 */
107
-	public function add_meta( $key, $value );
107
+	public function add_meta($key, $value);
108 108
 
109 109
 	/**
110 110
 	 * Update a piece of metadata for this reaction.
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return bool Whether the metadata was updated successfully.
118 118
 	 */
119
-	public function update_meta( $key, $value );
119
+	public function update_meta($key, $value);
120 120
 
121 121
 	/**
122 122
 	 * Delete a piece of metadata for this reaction.
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 * @return bool Whether the metadata was deleted successfully.
129 129
 	 */
130
-	public function delete_meta( $key );
130
+	public function delete_meta($key);
131 131
 
132 132
 	/**
133 133
 	 * Get all of the metadata for this reaction.
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/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 “%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.