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