Completed
Push — master ( 226003...873ec4 )
by J.D.
03:07
created
src/includes/classes/index.php 1 patch
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -10,113 +10,113 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // auto-generated {
13
-require_once( dirname( __FILE__ ) . 'app.php' );
14
-require_once( dirname( __FILE__ ) . 'app/registry.php' );
15
-require_once( dirname( __FILE__ ) . 'class/autoloader.php' );
16
-require_once( dirname( __FILE__ ) . 'class/registry.php' );
17
-require_once( dirname( __FILE__ ) . 'class/registry/children.php' );
18
-require_once( dirname( __FILE__ ) . 'class/registry/childreni.php' );
19
-require_once( dirname( __FILE__ ) . 'class/registry/persistent.php' );
20
-require_once( dirname( __FILE__ ) . 'class/registryi.php' );
21
-require_once( dirname( __FILE__ ) . 'data/type.php' );
22
-require_once( dirname( __FILE__ ) . 'data/type/integer.php' );
23
-require_once( dirname( __FILE__ ) . 'data/type/text.php' );
24
-require_once( dirname( __FILE__ ) . 'data/typei.php' );
25
-require_once( dirname( __FILE__ ) . 'db/query.php' );
26
-require_once( dirname( __FILE__ ) . 'entity.php' );
27
-require_once( dirname( __FILE__ ) . 'entity/array.php' );
28
-require_once( dirname( __FILE__ ) . 'entity/attr.php' );
29
-require_once( dirname( __FILE__ ) . 'entity/attr/field.php' );
30
-require_once( dirname( __FILE__ ) . 'entity/childi.php' );
31
-require_once( dirname( __FILE__ ) . 'entity/comment.php' );
32
-require_once( dirname( __FILE__ ) . 'entity/comment/author.php' );
33
-require_once( dirname( __FILE__ ) . 'entity/comment/post.php' );
34
-require_once( dirname( __FILE__ ) . 'entity/context.php' );
35
-require_once( dirname( __FILE__ ) . 'entity/context/network.php' );
36
-require_once( dirname( __FILE__ ) . 'entity/context/site.php' );
37
-require_once( dirname( __FILE__ ) . 'entity/enumerablei.php' );
38
-require_once( dirname( __FILE__ ) . 'entity/hierarchy.php' );
39
-require_once( dirname( __FILE__ ) . 'entity/hierarchyi.php' );
40
-require_once( dirname( __FILE__ ) . 'entity/parenti.php' );
41
-require_once( dirname( __FILE__ ) . 'entity/post.php' );
42
-require_once( dirname( __FILE__ ) . 'entity/post/author.php' );
43
-require_once( dirname( __FILE__ ) . 'entity/post/content.php' );
44
-require_once( dirname( __FILE__ ) . 'entity/post/terms.php' );
45
-require_once( dirname( __FILE__ ) . 'entity/post/type.php' );
46
-require_once( dirname( __FILE__ ) . 'entity/post/type/name.php' );
47
-require_once( dirname( __FILE__ ) . 'entity/post/type/relationship.php' );
48
-require_once( dirname( __FILE__ ) . 'entity/relationship.php' );
49
-require_once( dirname( __FILE__ ) . 'entity/relationship/dynamic.php' );
50
-require_once( dirname( __FILE__ ) . 'entity/relationship/stored/field.php' );
51
-require_once( dirname( __FILE__ ) . 'entity/restricted/visibilityi.php' );
52
-require_once( dirname( __FILE__ ) . 'entity/site.php' );
53
-require_once( dirname( __FILE__ ) . 'entity/stored/array.php' );
54
-require_once( dirname( __FILE__ ) . 'entity/stored/db/table.php' );
55
-require_once( dirname( __FILE__ ) . 'entity/term.php' );
56
-require_once( dirname( __FILE__ ) . 'entity/term/id.php' );
57
-require_once( dirname( __FILE__ ) . 'entity/user.php' );
58
-require_once( dirname( __FILE__ ) . 'entity/user/role.php' );
59
-require_once( dirname( __FILE__ ) . 'entity/user/role/name.php' );
60
-require_once( dirname( __FILE__ ) . 'entity/user/roles.php' );
61
-require_once( dirname( __FILE__ ) . 'entityish.php' );
62
-require_once( dirname( __FILE__ ) . 'entityish/storedi.php' );
63
-require_once( dirname( __FILE__ ) . 'entityishi.php' );
64
-require_once( dirname( __FILE__ ) . 'hierarchy.php' );
65
-require_once( dirname( __FILE__ ) . 'hook/action.php' );
66
-require_once( dirname( __FILE__ ) . 'hook/action/comment/new.php' );
67
-require_once( dirname( __FILE__ ) . 'hook/action/post/publish.php' );
68
-require_once( dirname( __FILE__ ) . 'hook/actioni.php' );
69
-require_once( dirname( __FILE__ ) . 'hook/actions.php' );
70
-require_once( dirname( __FILE__ ) . 'hook/arg.php' );
71
-require_once( dirname( __FILE__ ) . 'hook/arg/current/post.php' );
72
-require_once( dirname( __FILE__ ) . 'hook/arg/current/site.php' );
73
-require_once( dirname( __FILE__ ) . 'hook/arg/current/user.php' );
74
-require_once( dirname( __FILE__ ) . 'hook/arg/dynamic.php' );
75
-require_once( dirname( __FILE__ ) . 'hook/condition.php' );
76
-require_once( dirname( __FILE__ ) . 'hook/condition/entity/array/contains.php' );
77
-require_once( dirname( __FILE__ ) . 'hook/condition/equals.php' );
78
-require_once( dirname( __FILE__ ) . 'hook/condition/string/contains.php' );
79
-require_once( dirname( __FILE__ ) . 'hook/conditioni.php' );
80
-require_once( dirname( __FILE__ ) . 'hook/event.php' );
81
-require_once( dirname( __FILE__ ) . 'hook/event/args.php' );
82
-require_once( dirname( __FILE__ ) . 'hook/event/comment/leave.php' );
83
-require_once( dirname( __FILE__ ) . 'hook/event/dynamic.php' );
84
-require_once( dirname( __FILE__ ) . 'hook/event/media/upload.php' );
85
-require_once( dirname( __FILE__ ) . 'hook/event/post/publish.php' );
86
-require_once( dirname( __FILE__ ) . 'hook/event/user/register.php' );
87
-require_once( dirname( __FILE__ ) . 'hook/event/user/visit.php' );
88
-require_once( dirname( __FILE__ ) . 'hook/eventi.php' );
89
-require_once( dirname( __FILE__ ) . 'hook/events.php' );
90
-require_once( dirname( __FILE__ ) . 'hook/extension.php' );
91
-require_once( dirname( __FILE__ ) . 'hook/extension/blocker.php' );
92
-require_once( dirname( __FILE__ ) . 'hook/extension/conditions.php' );
93
-require_once( dirname( __FILE__ ) . 'hook/extension/periods.php' );
94
-require_once( dirname( __FILE__ ) . 'hook/fire.php' );
95
-require_once( dirname( __FILE__ ) . 'hook/hit/logger.php' );
96
-require_once( dirname( __FILE__ ) . 'hook/hit/query.php' );
97
-require_once( dirname( __FILE__ ) . 'hook/reaction.php' );
98
-require_once( dirname( __FILE__ ) . 'hook/reaction/options.php' );
99
-require_once( dirname( __FILE__ ) . 'hook/reaction/store.php' );
100
-require_once( dirname( __FILE__ ) . 'hook/reaction/store/options.php' );
101
-require_once( dirname( __FILE__ ) . 'hook/reaction/store/options/network.php' );
102
-require_once( dirname( __FILE__ ) . 'hook/reaction/storei.php' );
103
-require_once( dirname( __FILE__ ) . 'hook/reaction/validator.php' );
104
-require_once( dirname( __FILE__ ) . 'hook/reactioni.php' );
105
-require_once( dirname( __FILE__ ) . 'hook/reactor.php' );
106
-require_once( dirname( __FILE__ ) . 'hook/reactor/points.php' );
107
-require_once( dirname( __FILE__ ) . 'hook/retroactive/conditions.php' );
108
-require_once( dirname( __FILE__ ) . 'hook/retroactive/query.php' );
109
-require_once( dirname( __FILE__ ) . 'hook/retroactive/query/modifieri.php' );
110
-require_once( dirname( __FILE__ ) . 'hook/retroactive/queryable.php' );
111
-require_once( dirname( __FILE__ ) . 'hook/retroactive/queryi.php' );
112
-require_once( dirname( __FILE__ ) . 'hook/router.php' );
113
-require_once( dirname( __FILE__ ) . 'hook/settings.php' );
114
-require_once( dirname( __FILE__ ) . 'hook/settingsi.php' );
115
-require_once( dirname( __FILE__ ) . 'hook/validator/exception.php' );
116
-require_once( dirname( __FILE__ ) . 'hooks.php' );
117
-require_once( dirname( __FILE__ ) . 'query/builder/db/mysql.php' );
118
-require_once( dirname( __FILE__ ) . 'spec.php' );
119
-require_once( dirname( __FILE__ ) . 'specedi.php' );
13
+require_once(dirname(__FILE__).'app.php');
14
+require_once(dirname(__FILE__).'app/registry.php');
15
+require_once(dirname(__FILE__).'class/autoloader.php');
16
+require_once(dirname(__FILE__).'class/registry.php');
17
+require_once(dirname(__FILE__).'class/registry/children.php');
18
+require_once(dirname(__FILE__).'class/registry/childreni.php');
19
+require_once(dirname(__FILE__).'class/registry/persistent.php');
20
+require_once(dirname(__FILE__).'class/registryi.php');
21
+require_once(dirname(__FILE__).'data/type.php');
22
+require_once(dirname(__FILE__).'data/type/integer.php');
23
+require_once(dirname(__FILE__).'data/type/text.php');
24
+require_once(dirname(__FILE__).'data/typei.php');
25
+require_once(dirname(__FILE__).'db/query.php');
26
+require_once(dirname(__FILE__).'entity.php');
27
+require_once(dirname(__FILE__).'entity/array.php');
28
+require_once(dirname(__FILE__).'entity/attr.php');
29
+require_once(dirname(__FILE__).'entity/attr/field.php');
30
+require_once(dirname(__FILE__).'entity/childi.php');
31
+require_once(dirname(__FILE__).'entity/comment.php');
32
+require_once(dirname(__FILE__).'entity/comment/author.php');
33
+require_once(dirname(__FILE__).'entity/comment/post.php');
34
+require_once(dirname(__FILE__).'entity/context.php');
35
+require_once(dirname(__FILE__).'entity/context/network.php');
36
+require_once(dirname(__FILE__).'entity/context/site.php');
37
+require_once(dirname(__FILE__).'entity/enumerablei.php');
38
+require_once(dirname(__FILE__).'entity/hierarchy.php');
39
+require_once(dirname(__FILE__).'entity/hierarchyi.php');
40
+require_once(dirname(__FILE__).'entity/parenti.php');
41
+require_once(dirname(__FILE__).'entity/post.php');
42
+require_once(dirname(__FILE__).'entity/post/author.php');
43
+require_once(dirname(__FILE__).'entity/post/content.php');
44
+require_once(dirname(__FILE__).'entity/post/terms.php');
45
+require_once(dirname(__FILE__).'entity/post/type.php');
46
+require_once(dirname(__FILE__).'entity/post/type/name.php');
47
+require_once(dirname(__FILE__).'entity/post/type/relationship.php');
48
+require_once(dirname(__FILE__).'entity/relationship.php');
49
+require_once(dirname(__FILE__).'entity/relationship/dynamic.php');
50
+require_once(dirname(__FILE__).'entity/relationship/stored/field.php');
51
+require_once(dirname(__FILE__).'entity/restricted/visibilityi.php');
52
+require_once(dirname(__FILE__).'entity/site.php');
53
+require_once(dirname(__FILE__).'entity/stored/array.php');
54
+require_once(dirname(__FILE__).'entity/stored/db/table.php');
55
+require_once(dirname(__FILE__).'entity/term.php');
56
+require_once(dirname(__FILE__).'entity/term/id.php');
57
+require_once(dirname(__FILE__).'entity/user.php');
58
+require_once(dirname(__FILE__).'entity/user/role.php');
59
+require_once(dirname(__FILE__).'entity/user/role/name.php');
60
+require_once(dirname(__FILE__).'entity/user/roles.php');
61
+require_once(dirname(__FILE__).'entityish.php');
62
+require_once(dirname(__FILE__).'entityish/storedi.php');
63
+require_once(dirname(__FILE__).'entityishi.php');
64
+require_once(dirname(__FILE__).'hierarchy.php');
65
+require_once(dirname(__FILE__).'hook/action.php');
66
+require_once(dirname(__FILE__).'hook/action/comment/new.php');
67
+require_once(dirname(__FILE__).'hook/action/post/publish.php');
68
+require_once(dirname(__FILE__).'hook/actioni.php');
69
+require_once(dirname(__FILE__).'hook/actions.php');
70
+require_once(dirname(__FILE__).'hook/arg.php');
71
+require_once(dirname(__FILE__).'hook/arg/current/post.php');
72
+require_once(dirname(__FILE__).'hook/arg/current/site.php');
73
+require_once(dirname(__FILE__).'hook/arg/current/user.php');
74
+require_once(dirname(__FILE__).'hook/arg/dynamic.php');
75
+require_once(dirname(__FILE__).'hook/condition.php');
76
+require_once(dirname(__FILE__).'hook/condition/entity/array/contains.php');
77
+require_once(dirname(__FILE__).'hook/condition/equals.php');
78
+require_once(dirname(__FILE__).'hook/condition/string/contains.php');
79
+require_once(dirname(__FILE__).'hook/conditioni.php');
80
+require_once(dirname(__FILE__).'hook/event.php');
81
+require_once(dirname(__FILE__).'hook/event/args.php');
82
+require_once(dirname(__FILE__).'hook/event/comment/leave.php');
83
+require_once(dirname(__FILE__).'hook/event/dynamic.php');
84
+require_once(dirname(__FILE__).'hook/event/media/upload.php');
85
+require_once(dirname(__FILE__).'hook/event/post/publish.php');
86
+require_once(dirname(__FILE__).'hook/event/user/register.php');
87
+require_once(dirname(__FILE__).'hook/event/user/visit.php');
88
+require_once(dirname(__FILE__).'hook/eventi.php');
89
+require_once(dirname(__FILE__).'hook/events.php');
90
+require_once(dirname(__FILE__).'hook/extension.php');
91
+require_once(dirname(__FILE__).'hook/extension/blocker.php');
92
+require_once(dirname(__FILE__).'hook/extension/conditions.php');
93
+require_once(dirname(__FILE__).'hook/extension/periods.php');
94
+require_once(dirname(__FILE__).'hook/fire.php');
95
+require_once(dirname(__FILE__).'hook/hit/logger.php');
96
+require_once(dirname(__FILE__).'hook/hit/query.php');
97
+require_once(dirname(__FILE__).'hook/reaction.php');
98
+require_once(dirname(__FILE__).'hook/reaction/options.php');
99
+require_once(dirname(__FILE__).'hook/reaction/store.php');
100
+require_once(dirname(__FILE__).'hook/reaction/store/options.php');
101
+require_once(dirname(__FILE__).'hook/reaction/store/options/network.php');
102
+require_once(dirname(__FILE__).'hook/reaction/storei.php');
103
+require_once(dirname(__FILE__).'hook/reaction/validator.php');
104
+require_once(dirname(__FILE__).'hook/reactioni.php');
105
+require_once(dirname(__FILE__).'hook/reactor.php');
106
+require_once(dirname(__FILE__).'hook/reactor/points.php');
107
+require_once(dirname(__FILE__).'hook/retroactive/conditions.php');
108
+require_once(dirname(__FILE__).'hook/retroactive/query.php');
109
+require_once(dirname(__FILE__).'hook/retroactive/query/modifieri.php');
110
+require_once(dirname(__FILE__).'hook/retroactive/queryable.php');
111
+require_once(dirname(__FILE__).'hook/retroactive/queryi.php');
112
+require_once(dirname(__FILE__).'hook/router.php');
113
+require_once(dirname(__FILE__).'hook/settings.php');
114
+require_once(dirname(__FILE__).'hook/settingsi.php');
115
+require_once(dirname(__FILE__).'hook/validator/exception.php');
116
+require_once(dirname(__FILE__).'hooks.php');
117
+require_once(dirname(__FILE__).'query/builder/db/mysql.php');
118
+require_once(dirname(__FILE__).'spec.php');
119
+require_once(dirname(__FILE__).'specedi.php');
120 120
 // }
121 121
 
122 122
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/reactor.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -131,21 +131,21 @@  discard block
 block discarded – undo
131 131
 	) {
132 132
 
133 133
 		if (
134
-			empty( $settings['target'] )
135
-			|| ! is_array( $settings['target'] )
134
+			empty($settings['target'])
135
+			|| ! is_array($settings['target'])
136 136
 		) {
137 137
 
138
-			$validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' );
138
+			$validator->add_error(__('Invalid target.', 'wordpoints'), 'target');
139 139
 
140 140
 		} else {
141 141
 
142
-			$target = $event_args->get_from_hierarchy( $settings['target'] );
142
+			$target = $event_args->get_from_hierarchy($settings['target']);
143 143
 
144 144
 			if (
145 145
 				! $target instanceof WordPoints_Entity
146
-				|| ! in_array( $target->get_slug(), (array) $this->arg_types )
146
+				|| ! in_array($target->get_slug(), (array) $this->arg_types)
147 147
 			) {
148
-				$validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' );
148
+				$validator->add_error(__('Invalid target.', 'wordpoints'), 'target');
149 149
 			}
150 150
 		}
151 151
 
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	/**
156 156
 	 * @since 1.0.0
157 157
 	 */
158
-	public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) {
159
-		$reaction->update_meta( 'target', $settings['target'] );
158
+	public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) {
159
+		$reaction->update_meta('target', $settings['target']);
160 160
 	}
161 161
 
162 162
 	/**
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 	 * @param string               $hit_type The type of hit to perform.
168 168
 	 * @param WordPoints_Hook_Fire $fire     The hook fire object.
169 169
 	 */
170
-	public function hit( $hit_type, WordPoints_Hook_Fire $fire ) {
170
+	public function hit($hit_type, WordPoints_Hook_Fire $fire) {
171 171
 
172
-		if ( in_array( $hit_type, (array) $this->hit_types ) ) {
172
+		if (in_array($hit_type, (array) $this->hit_types)) {
173 173
 
174
-			call_user_func( array( $this, $hit_type ), $fire );
174
+			call_user_func(array($this, $hit_type), $fire);
175 175
 
176 176
 		} else {
177 177
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			 * @param string               $hit_type The type of hit to perform.
184 184
 			 * @param WordPoints_Hook_Fire $fire     The hook fire object.
185 185
 			 */
186
-			do_action( "wordpoints_hook_reactor_hit-{$this->slug}", $hit_type, $fire );
186
+			do_action("wordpoints_hook_reactor_hit-{$this->slug}", $hit_type, $fire);
187 187
 		}
188 188
 	}
189 189
 }
Please login to merge, or discard this patch.
src/includes/classes/hook/router.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 	/**
87 87
 	 * @since 1.0.0
88 88
 	 */
89
-	public function __call( $name, $args ) {
89
+	public function __call($name, $args) {
90 90
 
91
-		$this->route_action( $name, $args );
91
+		$this->route_action($name, $args);
92 92
 
93 93
 		// Return the first value, in case it is hooked to a filter.
94 94
 		$return = null;
95
-		if ( isset( $args[0] ) ) {
95
+		if (isset($args[0])) {
96 96
 			$return = $args[0];
97 97
 		}
98 98
 
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 	 *                     action name and the priority.
110 110
 	 * @param array  $args The args the action was fired with.
111 111
 	 */
112
-	protected function route_action( $name, $args ) {
112
+	protected function route_action($name, $args) {
113 113
 
114
-		if ( ! isset( $this->action_index[ $name ] ) ) {
114
+		if ( ! isset($this->action_index[$name])) {
115 115
 			return;
116 116
 		}
117 117
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		// registry attempts to access the router in its own constructor. The result
120 120
 		// of attempting to do this before the router itself has been fully
121 121
 		// constructed is that the events registry gets null instead of the router.
122
-		if ( ! isset( $this->actions ) ) {
122
+		if ( ! isset($this->actions)) {
123 123
 
124 124
 			$hooks = wordpoints_hooks();
125 125
 
@@ -127,38 +127,38 @@  discard block
 block discarded – undo
127 127
 			$this->actions = $hooks->actions;
128 128
 		}
129 129
 
130
-		foreach ( $this->action_index[ $name ]['actions'] as $slug => $data ) {
130
+		foreach ($this->action_index[$name]['actions'] as $slug => $data) {
131 131
 
132
-			if ( ! isset( $this->event_index[ $slug ] ) ) {
132
+			if ( ! isset($this->event_index[$slug])) {
133 133
 				continue;
134 134
 			}
135 135
 
136
-			$action_object = $this->actions->get( $slug, $args, $data );
136
+			$action_object = $this->actions->get($slug, $args, $data);
137 137
 
138
-			if ( ! ( $action_object instanceof WordPoints_Hook_ActionI ) ) {
138
+			if ( ! ($action_object instanceof WordPoints_Hook_ActionI)) {
139 139
 				continue;
140 140
 			}
141 141
 
142
-			if ( ! $action_object->should_fire() ) {
142
+			if ( ! $action_object->should_fire()) {
143 143
 				continue;
144 144
 			}
145 145
 
146
-			foreach ( $this->event_index[ $slug ] as $type => $events ) {
147
-				foreach ( $events as $event_slug => $unused ) {
146
+			foreach ($this->event_index[$slug] as $type => $events) {
147
+				foreach ($events as $event_slug => $unused) {
148 148
 
149
-					if ( ! $this->events->is_registered( $event_slug ) ) {
149
+					if ( ! $this->events->is_registered($event_slug)) {
150 150
 						continue;
151 151
 					}
152 152
 
153
-					$event_args = $this->events->args->get_children( $event_slug, array( $action_object ) );
153
+					$event_args = $this->events->args->get_children($event_slug, array($action_object));
154 154
 
155
-					if ( empty( $event_args ) ) {
155
+					if (empty($event_args)) {
156 156
 						continue;
157 157
 					}
158 158
 
159
-					$event_args = new WordPoints_Hook_Event_Args( $event_args );
159
+					$event_args = new WordPoints_Hook_Event_Args($event_args);
160 160
 
161
-					$this->fire_event( $type, $event_slug, $event_args );
161
+					$this->fire_event($type, $event_slug, $event_args);
162 162
 				}
163 163
 			}
164 164
 		}
@@ -182,19 +182,19 @@  discard block
 block discarded – undo
182 182
 
183 183
 		$hooks = wordpoints_hooks();
184 184
 
185
-		foreach ( $hooks->reaction_stores->get_all() as $reaction_stores ) {
186
-			foreach ( $reaction_stores as $reaction_store ) {
185
+		foreach ($hooks->reaction_stores->get_all() as $reaction_stores) {
186
+			foreach ($reaction_stores as $reaction_store) {
187 187
 
188
-				if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) {
188
+				if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) {
189 189
 					continue;
190 190
 				}
191 191
 
192 192
 				// Allowing access to stores out-of-context would lead to strange behavior.
193
-				if ( false === $reaction_store->get_context_id() ) {
193
+				if (false === $reaction_store->get_context_id()) {
194 194
 					continue;
195 195
 				}
196 196
 
197
-				foreach ( $reaction_store->get_reactions_to_event( $event_slug ) as $reaction ) {
197
+				foreach ($reaction_store->get_reactions_to_event($event_slug) as $reaction) {
198 198
 
199 199
 					$fire = new WordPoints_Hook_Fire(
200 200
 						$action_type
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 						, $reaction
203 203
 					);
204 204
 
205
-					$this->fire_reaction( $fire );
205
+					$this->fire_reaction($fire);
206 206
 				}
207 207
 			}
208 208
 		}
@@ -215,32 +215,32 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @param WordPoints_Hook_Fire $fire The hook fire object.
217 217
 	 */
218
-	protected function fire_reaction( $fire ) {
218
+	protected function fire_reaction($fire) {
219 219
 
220 220
 		$hooks = wordpoints_hooks();
221 221
 
222 222
 		$reactor_slug = $fire->reaction->get_reactor_slug();
223 223
 
224
-		if ( ! isset( $this->reactor_index[ $reactor_slug ][ $fire->action_type ] ) ) {
224
+		if ( ! isset($this->reactor_index[$reactor_slug][$fire->action_type])) {
225 225
 			return;
226 226
 		}
227 227
 
228
-		$hit_type = $this->reactor_index[ $reactor_slug ][ $fire->action_type ];
228
+		$hit_type = $this->reactor_index[$reactor_slug][$fire->action_type];
229 229
 
230
-		$validator = new WordPoints_Hook_Reaction_Validator( $fire->reaction, true );
230
+		$validator = new WordPoints_Hook_Reaction_Validator($fire->reaction, true);
231 231
 		$validator->validate();
232 232
 
233
-		if ( $validator->had_errors() ) {
233
+		if ($validator->had_errors()) {
234 234
 			return;
235 235
 		}
236 236
 
237
-		unset( $validator );
237
+		unset($validator);
238 238
 
239 239
 		/** @var WordPoints_Hook_Extension[] $extensions */
240 240
 		$extensions = $hooks->extensions->get_all();
241 241
 
242
-		foreach ( $extensions as $extension ) {
243
-			if ( ! $extension->should_hit( $fire ) ) {
242
+		foreach ($extensions as $extension) {
243
+			if ( ! $extension->should_hit($fire)) {
244 244
 				return;
245 245
 			}
246 246
 		}
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
 		$fire->hit();
249 249
 
250 250
 		/** @var WordPoints_Hook_Reactor $reactor */
251
-		$reactor = $hooks->reactors->get( $reactor_slug );
251
+		$reactor = $hooks->reactors->get($reactor_slug);
252 252
 
253
-		$reactor->hit( $hit_type, $fire );
253
+		$reactor->hit($hit_type, $fire);
254 254
 
255
-		foreach ( $extensions as $extension ) {
256
-			$extension->after_hit( $fire );
255
+		foreach ($extensions as $extension) {
256
+			$extension->after_hit($fire);
257 257
 		}
258 258
 	}
259 259
 
@@ -280,56 +280,56 @@  discard block
 block discarded – undo
280 280
 	 *        }
281 281
 	 * }
282 282
 	 */
283
-	public function add_action( $slug, array $args ) {
283
+	public function add_action($slug, array $args) {
284 284
 
285 285
 		$priority = 10;
286
-		if ( isset( $args['priority'] ) ) {
286
+		if (isset($args['priority'])) {
287 287
 			$priority = $args['priority'];
288 288
 		}
289 289
 
290
-		if ( ! isset( $args['action'] ) ) {
290
+		if ( ! isset($args['action'])) {
291 291
 			return;
292 292
 		}
293 293
 
294 294
 		$method = "{$args['action']},{$priority}";
295 295
 
296
-		$this->action_index[ $method ]['actions'][ $slug ] = array();
296
+		$this->action_index[$method]['actions'][$slug] = array();
297 297
 
298 298
 		$arg_number = 1;
299 299
 
300
-		if ( isset( $args['data'] ) ) {
300
+		if (isset($args['data'])) {
301 301
 
302
-			if ( isset( $args['data']['arg_index'] ) ) {
303
-				$arg_number = 1 + max( $args['data']['arg_index'] );
302
+			if (isset($args['data']['arg_index'])) {
303
+				$arg_number = 1 + max($args['data']['arg_index']);
304 304
 			}
305 305
 
306
-			if ( isset( $args['data']['requirements'] ) ) {
307
-				$requirements = 1 + max( array_keys( $args['data']['requirements'] ) );
306
+			if (isset($args['data']['requirements'])) {
307
+				$requirements = 1 + max(array_keys($args['data']['requirements']));
308 308
 
309
-				if ( $requirements > $arg_number ) {
309
+				if ($requirements > $arg_number) {
310 310
 					$arg_number = $requirements;
311 311
 				}
312 312
 			}
313 313
 
314
-			$this->action_index[ $method ]['actions'][ $slug ] = $args['data'];
314
+			$this->action_index[$method]['actions'][$slug] = $args['data'];
315 315
 		}
316 316
 
317
-		if ( isset( $args['arg_number'] ) ) {
317
+		if (isset($args['arg_number'])) {
318 318
 			$arg_number = $args['arg_number'];
319 319
 		}
320 320
 
321 321
 		// If this action is already being routed, and will have enough args, we
322 322
 		// don't need to hook to it again.
323 323
 		if (
324
-			isset( $this->action_index[ $method ]['arg_number'] )
325
-			&& $this->action_index[ $method ]['arg_number'] >= $arg_number
324
+			isset($this->action_index[$method]['arg_number'])
325
+			&& $this->action_index[$method]['arg_number'] >= $arg_number
326 326
 		) {
327 327
 			return;
328 328
 		}
329 329
 
330
-		$this->action_index[ $method ]['arg_number'] = $arg_number;
330
+		$this->action_index[$method]['arg_number'] = $arg_number;
331 331
 
332
-		add_action( $args['action'], array( $this, $method ), $priority, $arg_number );
332
+		add_action($args['action'], array($this, $method), $priority, $arg_number);
333 333
 	}
334 334
 
335 335
 	/**
@@ -339,20 +339,20 @@  discard block
 block discarded – undo
339 339
 	 *
340 340
 	 * @param string $slug The action slug.
341 341
 	 */
342
-	public function remove_action( $slug ) {
342
+	public function remove_action($slug) {
343 343
 
344
-		foreach ( $this->action_index as $method => $data ) {
345
-			if ( isset( $data['actions'][ $slug ] ) ) {
344
+		foreach ($this->action_index as $method => $data) {
345
+			if (isset($data['actions'][$slug])) {
346 346
 
347
-				unset( $this->action_index[ $method ]['actions'][ $slug ] );
347
+				unset($this->action_index[$method]['actions'][$slug]);
348 348
 
349
-				if ( empty( $this->action_index[ $method ]['actions'] ) ) {
349
+				if (empty($this->action_index[$method]['actions'])) {
350 350
 
351
-					unset( $this->action_index[ $method ] );
351
+					unset($this->action_index[$method]);
352 352
 
353
-					list( $action, $priority ) = explode( ',', $method );
353
+					list($action, $priority) = explode(',', $method);
354 354
 
355
-					remove_action( $action, array( $this, $method ), $priority );
355
+					remove_action($action, array($this, $method), $priority);
356 356
 				}
357 357
 			}
358 358
 		}
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	 * @param string $action_slug The slug of the action.
368 368
 	 * @param string $action_type The type of action. Default is 'fire'.
369 369
 	 */
370
-	public function add_event_to_action( $event_slug, $action_slug, $action_type = 'fire' ) {
371
-		$this->event_index[ $action_slug ][ $action_type ][ $event_slug ] = true;
370
+	public function add_event_to_action($event_slug, $action_slug, $action_type = 'fire') {
371
+		$this->event_index[$action_slug][$action_type][$event_slug] = true;
372 372
 	}
373 373
 
374 374
 	/**
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 	 * @param string $action_slug The slug of the action.
381 381
 	 * @param string $action_type The type of action. Default is 'fire'.
382 382
 	 */
383
-	public function remove_event_from_action( $event_slug, $action_slug, $action_type = 'fire' ) {
384
-		unset( $this->event_index[ $action_slug ][ $action_type ][ $event_slug ] );
383
+	public function remove_event_from_action($event_slug, $action_slug, $action_type = 'fire') {
384
+		unset($this->event_index[$action_slug][$action_type][$event_slug]);
385 385
 	}
386 386
 
387 387
 	/**
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @param string $hit_type     The type of hit the reactor should perform when
395 395
 	 *                             hit by this type of event.
396 396
 	 */
397
-	public function add_action_type_to_reactor( $action_type, $reactor_slug, $hit_type ) {
398
-		$this->reactor_index[ $reactor_slug ][ $action_type ] = $hit_type;
397
+	public function add_action_type_to_reactor($action_type, $reactor_slug, $hit_type) {
398
+		$this->reactor_index[$reactor_slug][$action_type] = $hit_type;
399 399
 	}
400 400
 
401 401
 	/**
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
 	 * @param string $action_type  The slug of the action type.
407 407
 	 * @param string $reactor_slug The slug of the reactor.
408 408
 	 */
409
-	public function remove_action_type_from_reactor( $action_type, $reactor_slug ) {
410
-		unset( $this->reactor_index[ $reactor_slug ][ $action_type ] );
409
+	public function remove_action_type_from_reactor($action_type, $reactor_slug) {
410
+		unset($this->reactor_index[$reactor_slug][$action_type]);
411 411
 	}
412 412
 
413 413
 	/**
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	 */
420 420
 	public function get_event_index() {
421 421
 
422
-		if ( empty( $this->reactor_index ) ) {
422
+		if (empty($this->reactor_index)) {
423 423
 			wordpoints_hooks()->events;
424 424
 		}
425 425
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	 */
436 436
 	public function get_reactor_index() {
437 437
 
438
-		if ( empty( $this->reactor_index ) ) {
438
+		if (empty($this->reactor_index)) {
439 439
 			wordpoints_hooks()->reactors;
440 440
 		}
441 441
 
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,18 +35,18 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * @since 1.0.0
37 37
 	 */
38
-	public function __construct( $id, WordPoints_Hook_Reaction_StoreI $store ) {
38
+	public function __construct($id, WordPoints_Hook_Reaction_StoreI $store) {
39 39
 
40
-		$this->ID    = wordpoints_int( $id );
40
+		$this->ID    = wordpoints_int($id);
41 41
 		$this->store = $store;
42 42
 	}
43 43
 
44 44
 	/**
45 45
 	 * @since 1.0.0
46 46
 	 */
47
-	public function __get( $var ) {
47
+	public function __get($var) {
48 48
 
49
-		if ( 'ID' === $var ) {
49
+		if ('ID' === $var) {
50 50
 			return $this->ID;
51 51
 		}
52 52
 
@@ -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' ); // TODO remove this method?
72
+		return $this->get_meta('reactor'); // TODO remove this method?
73 73
 	}
74 74
 
75 75
 	/**
Please login to merge, or discard this patch.
src/includes/classes/hook/retroactive/query.php 1 patch
Spacing   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 
74 74
 
75 75
 interface WordPoints_Hook_Reactor_RetroactiveI extends WordPoints_Hook_Retroactive_Query_ModifierI {
76
-	public function retroactive_hit( $target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction );
76
+	public function retroactive_hit($target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction);
77 77
 }
78 78
 
79 79
 abstract class WordPoints_Hook_Reactor_Retroactive implements WordPoints_Hook_Reactor_RetroactiveI {
80 80
 
81
-	public function modify_retroactive_query( WordPoints_Hook_Retroactive_QueryI $query ) {
81
+	public function modify_retroactive_query(WordPoints_Hook_Retroactive_QueryI $query) {
82 82
 
83
-		$query->set_target( $query->get_reaction()->get_meta( 'target' ) );
83
+		$query->set_target($query->get_reaction()->get_meta('target'));
84 84
 	}
85 85
 
86 86
 	public function reverse_hits() {
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 	/**
98 98
 	 * @since 1.0.0
99 99
 	 */
100
-	public function retroactive_hit( $target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction ) {
100
+	public function retroactive_hit($target, array $records, WordPoints_Hook_Event_RetroactiveI $event, WordPoints_Hook_ReactionI $reaction) {
101 101
 
102
-		$count = count( $records );
102
+		$count = count($records);
103 103
 
104 104
 		wordpoints_alter_points(
105 105
 			$target
106
-			, $reaction->get_meta( 'points' ) * $count
107
-			, $reaction->get_meta( 'points_type' )
108
-			, 'retroactive_' . $reaction->get_event_slug()
109
-			, array( 'count' => $count )
110
-			, $event->get_retroactive_description( $reaction )
106
+			, $reaction->get_meta('points') * $count
107
+			, $reaction->get_meta('points_type')
108
+			, 'retroactive_'.$reaction->get_event_slug()
109
+			, array('count' => $count)
110
+			, $event->get_retroactive_description($reaction)
111 111
 		);
112 112
 	}
113 113
 
@@ -139,22 +139,22 @@  discard block
 block discarded – undo
139 139
 
140 140
 		$logs = $query->get();
141 141
 
142
-		if ( ! $logs ) {
142
+		if ( ! $logs) {
143 143
 			return;
144 144
 		}
145 145
 
146
-		foreach ( $logs as $log ) {
146
+		foreach ($logs as $log) {
147 147
 
148 148
 			wordpoints_alter_points(
149 149
 				$log->user_id
150
-				, - ( $log->points / wordpoints_get_points_log_meta( $log->id, 'count', true ) )
150
+				, -($log->points / wordpoints_get_points_log_meta($log->id, 'count', true))
151 151
 				, $log->points_type
152 152
 				, "reverse_{$event}"
153
-				, array( 'original_log_id' => $log->id )
153
+				, array('original_log_id' => $log->id)
154 154
 				, $args->get_description()
155 155
 			);
156 156
 
157
-			wordpoints_add_points_log_meta( $log->id, 'auto_reversed', $args->get_entity_id() );
157
+			wordpoints_add_points_log_meta($log->id, 'auto_reversed', $args->get_entity_id());
158 158
 		}
159 159
 	}
160 160
 }
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
 
197 197
 	protected $results;
198 198
 
199
-	public function __construct( WordPoints_Hook_ReactionI $reaction ) {
199
+	public function __construct(WordPoints_Hook_ReactionI $reaction) {
200 200
 
201 201
 		$this->reaction = $reaction;
202
-		$this->arg_hierarchy = new WordPoints_Hierarchy( 'sub_args' );
202
+		$this->arg_hierarchy = new WordPoints_Hierarchy('sub_args');
203 203
 		$this->hooks = wordpoints_hooks();
204 204
 		$this->entities = wordpoints_entities();
205
-		$this->validator = new WordPoints_Hook_Reaction_Validator( $reaction, true );
205
+		$this->validator = new WordPoints_Hook_Reaction_Validator($reaction, true);
206 206
 	}
207 207
 
208 208
 	public function get_reaction() {
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 
216 216
 	public function get_results() {
217 217
 
218
-		if ( ! isset( $this->results ) ) {
218
+		if ( ! isset($this->results)) {
219 219
 
220 220
 			$this->execute();
221 221
 
222
-			if ( $this->validator->had_errors() ) {
222
+			if ($this->validator->had_errors()) {
223 223
 				$this->results = $this->validator;
224 224
 			}
225 225
 		}
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 			$this->filter_results();
237 237
 			$this->group_results();
238 238
 
239
-		} catch ( WordPoints_Hook_Validator_Exception $e ) {
240
-			unset( $e );
239
+		} catch (WordPoints_Hook_Validator_Exception $e) {
240
+			unset($e);
241 241
 		}
242 242
 	}
243 243
 
@@ -245,32 +245,32 @@  discard block
 block discarded – undo
245 245
 
246 246
 		$event_slug = $this->reaction->get_event_slug();
247 247
 
248
-		$event = $this->hooks->events->get( $event_slug );
248
+		$event = $this->hooks->events->get($event_slug);
249 249
 
250
-		if ( ! ( $event instanceof WordPoints_Hook_Event_RetroactiveI ) ) {
251
-			$this->validator->add_error( 'invalid hook' );
250
+		if ( ! ($event instanceof WordPoints_Hook_Event_RetroactiveI)) {
251
+			$this->validator->add_error('invalid hook');
252 252
 		}
253 253
 
254
-		foreach ( $this->hooks->events->args->get_children( $event_slug ) as $arg ) {
254
+		foreach ($this->hooks->events->args->get_children($event_slug) as $arg) {
255 255
 			$this->arg_hierarchy_push( // TODO
256 256
 				$arg
257 257
 			);
258 258
 		}
259 259
 
260
-		if ( $event instanceof WordPoints_Hook_Retroactive_Query_ModifierI ) {
261
-			$event->modify_retroactive_query( $this );
260
+		if ($event instanceof WordPoints_Hook_Retroactive_Query_ModifierI) {
261
+			$event->modify_retroactive_query($this);
262 262
 			$this->reset();
263 263
 		}
264 264
 
265
-		$reactor = $this->hooks->reactors->get( $this->reaction->get_reactor_slug() );
265
+		$reactor = $this->hooks->reactors->get($this->reaction->get_reactor_slug());
266 266
 
267
-		$reactor->modify_retroactive_query( $this );
267
+		$reactor->modify_retroactive_query($this);
268 268
 		$this->reset();
269 269
 
270
-		foreach ( $this->hooks->extensions->get_all() as $extension ) {
270
+		foreach ($this->hooks->extensions->get_all() as $extension) {
271 271
 
272
-			if ( $extension instanceof WordPoints_Hook_Retroactive_Query_ModifierI ) {
273
-				$extension->modify_retroactive_query( $this );
272
+			if ($extension instanceof WordPoints_Hook_Retroactive_Query_ModifierI) {
273
+				$extension->modify_retroactive_query($this);
274 274
 				$this->reset();
275 275
 			}
276 276
 		}
@@ -278,125 +278,125 @@  discard block
 block discarded – undo
278 278
 
279 279
 	protected function perform_query() {
280 280
 
281
-		$this->queries = new WordPoints_Hierarchy( 'sub_queries' );
282
-		$this->consolidate_queries( array( $this->arg_hierarchy->get() ) );
283
-		unset( $this->query );
281
+		$this->queries = new WordPoints_Hierarchy('sub_queries');
282
+		$this->consolidate_queries(array($this->arg_hierarchy->get()));
283
+		unset($this->query);
284 284
 
285 285
 		$this->queries->reset();
286 286
 
287 287
 		// Find the tip of a query.
288
-		$this->results = $this->execute_queries( $this->queries->get() );
288
+		$this->results = $this->execute_queries($this->queries->get());
289 289
 
290
-		if ( is_wp_error( $this->results ) ) {
291
-			$this->validator->add_error( $this->results );
290
+		if (is_wp_error($this->results)) {
291
+			$this->validator->add_error($this->results);
292 292
 		}
293 293
 	}
294 294
 
295
-	protected function consolidate_queries( $arg_hierarchy, $storage_type = null ) {
295
+	protected function consolidate_queries($arg_hierarchy, $storage_type = null) {
296 296
 
297
-		foreach ( $arg_hierarchy as $data ) {
298
-			$this->consolidate_query( $data );
297
+		foreach ($arg_hierarchy as $data) {
298
+			$this->consolidate_query($data);
299 299
 		}
300 300
 	}
301 301
 
302
-	protected function consolidate_query( $data ) {
302
+	protected function consolidate_query($data) {
303 303
 
304
-		if ( $data['storage_info']['type'] !== $this->queries->get_field( 'slug' ) ) {
304
+		if ($data['storage_info']['type'] !== $this->queries->get_field('slug')) {
305 305
 
306 306
 			$parent_id = null;
307
-			if ( isset( $this->query ) ) {
307
+			if (isset($this->query)) {
308 308
 				$parent_id = $this->query->get_id();
309 309
 			}
310 310
 
311
-			$this->query = new WordPoints_Hierarchy( 'sub_args' );
311
+			$this->query = new WordPoints_Hierarchy('sub_args');
312 312
 
313 313
 			$this->queries->push(
314 314
 				$data['storage_info']['type']
315
-				, array( 'query' => $this->query, 'parent_id' => $parent_id )
315
+				, array('query' => $this->query, 'parent_id' => $parent_id)
316 316
 			);
317 317
 
318 318
 			$pushed_query = true;
319 319
 		}
320 320
 
321
-		if ( isset( $data['sub_args'] ) ) {
321
+		if (isset($data['sub_args'])) {
322 322
 			$sub_args = $data['sub_args'];
323
-			unset( $data['sub_args'] );
323
+			unset($data['sub_args']);
324 324
 		}
325 325
 
326
-		$this->query->push( $data['slug'], $data );
326
+		$this->query->push($data['slug'], $data);
327 327
 
328
-		if ( isset( $sub_args ) ) {
329
-			$this->consolidate_queries( $sub_args, $data['storage_info']['type'] );
328
+		if (isset($sub_args)) {
329
+			$this->consolidate_queries($sub_args, $data['storage_info']['type']);
330 330
 		}
331 331
 
332 332
 		$this->query->pop();
333 333
 
334
-		if ( ! empty( $pushed_query ) ) {
334
+		if ( ! empty($pushed_query)) {
335 335
 			$this->queries->pop();
336
-			$this->query = $this->queries->get_field( 'query' );
336
+			$this->query = $this->queries->get_field('query');
337 337
 		}
338 338
 	}
339 339
 
340
-	protected function execute_queries( $queries ) {
340
+	protected function execute_queries($queries) {
341 341
 
342 342
 		/** @var WordPoints_HierarchyI $query */
343 343
 		$query = $queries['query'];
344 344
 
345
-		if ( isset( $queries['sub_queries'] ) ) {
346
-			foreach ( $queries['sub_queries'] as $query_data ) {
345
+		if (isset($queries['sub_queries'])) {
346
+			foreach ($queries['sub_queries'] as $query_data) {
347 347
 
348
-				$results = $this->execute_queries( $query_data );
348
+				$results = $this->execute_queries($query_data);
349 349
 
350
-				if ( is_wp_error( $results ) ) {
350
+				if (is_wp_error($results)) {
351 351
 					return $results;
352 352
 				}
353 353
 
354
-				if ( empty( $results ) ) {
354
+				if (empty($results)) {
355 355
 					return array();
356 356
 				}
357 357
 
358 358
 				/** @var WordPoints_HierarchyI $child_query */
359 359
 				$child_query = $query_data['query'];
360
-				$query->go_to( $query_data['parent_id'] );
360
+				$query->go_to($query_data['parent_id']);
361 361
 
362 362
 				$condition = array(
363 363
 //					'field' => $child_query->get_field( 'slug' ),
364 364
 					'compare' => 'in',
365 365
 					'value' => wp_list_pluck(
366 366
 						$results
367
-						, $child_query->get_field( 'storage_info', 'meta', 'id_field' )
367
+						, $child_query->get_field('storage_info', 'meta', 'id_field')
368 368
 					),
369 369
 				);
370 370
 
371
-				$query->push_to( 'conditions', $condition );
371
+				$query->push_to('conditions', $condition);
372 372
 			}
373 373
 		}
374 374
 
375 375
 		$query->reset();
376
-		$storage_type = $query->get_field( 'storage_info', 'type' );
376
+		$storage_type = $query->get_field('storage_info', 'type');
377 377
 
378
-		$executor = $this->hooks->retroactive_query_executors->get( $storage_type );
378
+		$executor = $this->hooks->retroactive_query_executors->get($storage_type);
379 379
 
380
-		if ( ! $executor ) {
380
+		if ( ! $executor) {
381 381
 			$this->validator->add_error(
382
-				sprintf( 'unknown storage type "%s".', $storage_type )
382
+				sprintf('unknown storage type "%s".', $storage_type)
383 383
 			);
384 384
 		}
385 385
 
386
-		return $executor->execute( array( $query->get() ) );
386
+		return $executor->execute(array($query->get()));
387 387
 	}
388 388
 
389 389
 	protected function filter_results() {
390 390
 
391
-		$reactor = $this->hooks->reactors->get( $this->reaction->get_reactor_slug() );
391
+		$reactor = $this->hooks->reactors->get($this->reaction->get_reactor_slug());
392 392
 
393
-		if ( $reactor instanceof WordPoints_Hook_Retroactive_Query_FilterI ) {
394
-			$reactor->filter_retroactive_query( $this );
393
+		if ($reactor instanceof WordPoints_Hook_Retroactive_Query_FilterI) {
394
+			$reactor->filter_retroactive_query($this);
395 395
 		}
396 396
 
397
-		foreach ( $this->hooks->extensions->get_all() as $extension ) {
398
-			if ( $extension instanceof WordPoints_Hook_Retroactive_Query_FilterI ) {
399
-				$extension->filter_retroactive_query( $this );
397
+		foreach ($this->hooks->extensions->get_all() as $extension) {
398
+			if ($extension instanceof WordPoints_Hook_Retroactive_Query_FilterI) {
399
+				$extension->filter_retroactive_query($this);
400 400
 			}
401 401
 		}
402 402
 	}
@@ -405,27 +405,27 @@  discard block
 block discarded – undo
405 405
 
406 406
 		$grouped_results = array();
407 407
 
408
-		foreach ( $this->results as $result ) {
409
-			$grouped_results[ $result->target ][] = $result;
408
+		foreach ($this->results as $result) {
409
+			$grouped_results[$result->target][] = $result;
410 410
 		}
411 411
 
412 412
 		$this->results = $grouped_results;
413 413
 	}
414 414
 
415
-	public function add_condition( array $condition ) {
415
+	public function add_condition(array $condition) {
416 416
 
417
-		$this->arg_hierarchy->push_to( 'conditions', $condition );
417
+		$this->arg_hierarchy->push_to('conditions', $condition);
418 418
 	}
419 419
 
420
-	public function select_value( $data = array() ) {
420
+	public function select_value($data = array()) {
421 421
 
422
-		$this->arg_hierarchy->set_field( 'select', $data );
422
+		$this->arg_hierarchy->set_field('select', $data);
423 423
 	}
424 424
 
425
-	public function set_target( $target_arg ) {
425
+	public function set_target($target_arg) {
426 426
 
427
-		foreach ( $target_arg as $arg_slug ) {
428
-			$this->arg_hierarchy_push( $arg_slug );
427
+		foreach ($target_arg as $arg_slug) {
428
+			$this->arg_hierarchy_push($arg_slug);
429 429
 		}
430 430
 
431 431
 //		$id = $this->arg_hierarchy->get_id();
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 //			$field = $this->arg_hierarchy->get_field( 'storage_info', 'meta', 'field' );
436 436
 //			$this->arg_hierarchy->ascend();
437 437
 //		} else {
438
-			$field = $this->arg_hierarchy->get_field( 'storage_info', 'meta', 'id_field' );
438
+			$field = $this->arg_hierarchy->get_field('storage_info', 'meta', 'id_field');
439 439
 //		}
440 440
 
441
-		$this->select_value( array( 'field' => $field, 'as' => 'target' ) );
441
+		$this->select_value(array('field' => $field, 'as' => 'target'));
442 442
 
443 443
 //		$this->arg_hierarchy->go_to( $id );
444 444
 	}
@@ -450,40 +450,40 @@  discard block
 block discarded – undo
450 450
 	 * @return WordPoints_EntityishI
451 451
 	 */
452 452
 	public function get_arg() {
453
-		return $this->arg_hierarchy->get_field( 'arg' );
453
+		return $this->arg_hierarchy->get_field('arg');
454 454
 	}
455 455
 
456
-	public function arg_hierarchy_push( $slug ) {
456
+	public function arg_hierarchy_push($slug) {
457 457
 
458
-		$current_slug = $this->arg_hierarchy->get_field( 'slug' );
458
+		$current_slug = $this->arg_hierarchy->get_field('slug');
459 459
 
460
-		if ( $current_slug === $slug && $this->arg_hierarchy->is_main() ) {
460
+		if ($current_slug === $slug && $this->arg_hierarchy->is_main()) {
461 461
 			return;
462 462
 		}
463 463
 
464 464
 //		if ( $current_slug !== $slug ) {
465 465
 
466
-			if ( empty( $current_slug ) ) {
467
-				$arg = $this->entities->get( $slug );
466
+			if (empty($current_slug)) {
467
+				$arg = $this->entities->get($slug);
468 468
 			} else {
469 469
 
470 470
 				// If this child exists, don't overwrite it, just descend into it.
471
-				if ( $this->arg_hierarchy->has_child( $slug ) ) {
472
-					$this->arg_hierarchy->descend( $slug );
471
+				if ($this->arg_hierarchy->has_child($slug)) {
472
+					$this->arg_hierarchy->descend($slug);
473 473
 					return;
474 474
 				}
475 475
 
476
-				$parent_arg = $this->arg_hierarchy->get_field( 'arg' );
476
+				$parent_arg = $this->arg_hierarchy->get_field('arg');
477 477
 
478
-				if ( $parent_arg instanceof WordPoints_Entity_ParentI ) {
479
-					$arg = $parent_arg->get_child( $slug );
478
+				if ($parent_arg instanceof WordPoints_Entity_ParentI) {
479
+					$arg = $parent_arg->get_child($slug);
480 480
 				} else {
481 481
 					return; // TODO
482 482
 				}
483 483
 			}
484 484
 
485
-			if ( $arg instanceof WordPoints_Entity_Array ) {
486
-				$arg = $this->entities->get( $arg->get_entity_slug() );
485
+			if ($arg instanceof WordPoints_Entity_Array) {
486
+				$arg = $this->entities->get($arg->get_entity_slug());
487 487
 			}
488 488
 
489 489
 			$data['arg'] = $arg;
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 			// TODO check if storage type is recognized?
492 492
 			$data['storage_info'] = $arg->get_storage_info();
493 493
 
494
-			$this->arg_hierarchy->push( $slug, $data );
494
+			$this->arg_hierarchy->push($slug, $data);
495 495
 
496 496
 //		} else {
497 497
 //			$data = array();
@@ -508,11 +508,11 @@  discard block
 block discarded – undo
508 508
 }
509 509
 
510 510
 interface WordPoints_Hook_Retroactive_Query_FilterI {
511
-	public function filter_retroactive_query( WordPoints_Hook_Retroactive_QueryI $query );
511
+	public function filter_retroactive_query(WordPoints_Hook_Retroactive_QueryI $query);
512 512
 }
513 513
 
514 514
 interface WordPoints_Hook_Retroactive_Query_ExecutorI {
515
-	public function execute( $query );
515
+	public function execute($query);
516 516
 }
517 517
 
518 518
 /*
@@ -541,48 +541,48 @@  discard block
 block discarded – undo
541 541
 	protected $array;
542 542
 	protected $results;
543 543
 
544
-	public function execute( $query ) {
544
+	public function execute($query) {
545 545
 
546
-		foreach ( $query as $arg_data ) {
546
+		foreach ($query as $arg_data) {
547 547
 
548 548
 			$meta = $arg_data['storage_info']['meta'];
549 549
 
550
-			if ( isset( $meta['getter'] ) ) {
550
+			if (isset($meta['getter'])) {
551 551
 				$this->array = $meta['getter']();
552 552
 			}
553 553
 
554
-			if ( isset( $arg_data['conditions'] ) ) {
554
+			if (isset($arg_data['conditions'])) {
555 555
 
556
-				foreach ( $arg_data['conditions'] as $condition ) {
556
+				foreach ($arg_data['conditions'] as $condition) {
557 557
 
558
-					if ( ! isset( $condition['field'] ) ) {
559
-						if ( $arg_data['arg'] instanceof WordPoints_Entity_Attr ) {
558
+					if ( ! isset($condition['field'])) {
559
+						if ($arg_data['arg'] instanceof WordPoints_Entity_Attr) {
560 560
 							$condition['field'] = $meta['field'];
561 561
 						} else {
562 562
 							$condition['field'] = $meta['id_field'];
563 563
 						}
564 564
 					}
565 565
 
566
-					if ( ! isset( $condition['condition'] ) ) {
566
+					if ( ! isset($condition['condition'])) {
567 567
 						$condition['condition'] = '=';
568 568
 					}
569 569
 
570 570
 					$filter_args = array();
571 571
 
572
-					switch ( $condition['condition'] ) {
572
+					switch ($condition['condition']) {
573 573
 
574 574
 						case '=':
575
-							$filter_args[ $condition['field'] ] = $condition['value'];
575
+							$filter_args[$condition['field']] = $condition['value'];
576 576
 							break;
577 577
 
578 578
 						case 'in':
579 579
 							// TODO
580 580
 
581 581
 						default:
582
-							return new WP_Error( 'invalid condition type' );
582
+							return new WP_Error('invalid condition type');
583 583
 					}
584 584
 
585
-					$this->array = wp_list_filter( $this->array, $filter_args );
585
+					$this->array = wp_list_filter($this->array, $filter_args);
586 586
 				}
587 587
 			}
588 588
 
@@ -590,9 +590,9 @@  discard block
 block discarded – undo
590 590
 //				$builder->add_field( $arg_data['select'] );
591 591
 //			}
592 592
 
593
-			if ( isset( $arg_data['sub_args'] ) ) {
593
+			if (isset($arg_data['sub_args'])) {
594 594
 				$this->parent_data = $arg_data;
595
-				$this->array = $this->execute( $arg_data['sub_args'] );
595
+				$this->array = $this->execute($arg_data['sub_args']);
596 596
 			}
597 597
 
598 598
 			$this->results = $this->array;
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	}
603 603
 }
604 604
 
605
-wordpoints_hooks()->retroactive_query_executors->register( 'array', 'WordPoints_Hook_Retroactive_Query_Executor_Array' );
605
+wordpoints_hooks()->retroactive_query_executors->register('array', 'WordPoints_Hook_Retroactive_Query_Executor_Array');
606 606
 
607 607
 class WordPoints_Hook_Retroactive_Query_Executor_MySQL
608 608
 	implements WordPoints_Hook_Retroactive_Query_ExecutorI {
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 
622 622
 	protected $entered_join;
623 623
 
624
-	public function execute( $query ) {
624
+	public function execute($query) {
625 625
 		// WE should be getting a hierarchy object here.
626 626
 		// This will let us loop over things easier.
627 627
 		// We'll also need to be marking the non-usable parts of the query.
@@ -631,69 +631,69 @@  discard block
 block discarded – undo
631 631
 
632 632
 		$this->builder = new WordPoints_Query_Builder_DB_MySQL();
633 633
 
634
-		$this->build_query( $query );
634
+		$this->build_query($query);
635 635
 
636 636
 		$sql = $this->builder->get_query();
637 637
 
638
-		if ( is_wp_error( $sql ) ) {
638
+		if (is_wp_error($sql)) {
639 639
 			return $sql;
640 640
 		}
641 641
 
642
-		return $wpdb->get_results( $sql );
642
+		return $wpdb->get_results($sql);
643 643
 	}
644 644
 
645
-	protected function build_query( $args ) {
645
+	protected function build_query($args) {
646 646
 
647
-		foreach ( $args as $arg_data ) {
647
+		foreach ($args as $arg_data) {
648 648
 
649 649
 			$this->arg_data = $arg_data;
650 650
 
651
-			if ( isset( $arg_data['storage_info']['meta']['table_name'] ) ) {
652
-				$this->build_table_schema( $arg_data['storage_info']['meta'] );
651
+			if (isset($arg_data['storage_info']['meta']['table_name'])) {
652
+				$this->build_table_schema($arg_data['storage_info']['meta']);
653 653
 			}
654 654
 
655
-			if ( isset( $arg_data['conditions'] ) ) {
656
-				$this->build_conditions( $arg_data['conditions'] );
655
+			if (isset($arg_data['conditions'])) {
656
+				$this->build_conditions($arg_data['conditions']);
657 657
 			}
658 658
 
659
-			if ( isset( $arg_data['select'] ) ) {
660
-				$this->builder->add_field( $arg_data['select'] );
659
+			if (isset($arg_data['select'])) {
660
+				$this->builder->add_field($arg_data['select']);
661 661
 			}
662 662
 
663
-			if ( isset( $arg_data['sub_args'] ) ) {
663
+			if (isset($arg_data['sub_args'])) {
664 664
 
665 665
 				$this->grandparent_data = $this->parent_data;
666 666
 				$this->parent_data = $arg_data;
667 667
 
668
-				$this->build_query( $arg_data['sub_args'] );
668
+				$this->build_query($arg_data['sub_args']);
669 669
 
670 670
 				$this->parent_data = $this->grandparent_data;
671 671
 			}
672 672
 
673
-			if ( isset( $this->entered_join ) ) {
673
+			if (isset($this->entered_join)) {
674 674
 				$this->builder->exit_join();
675 675
 				$this->entered_join = null;
676 676
 			}
677 677
 		}
678 678
 	}
679 679
 
680
-	protected function build_table_schema( $db ) {
680
+	protected function build_table_schema($db) {
681 681
 
682
-		if ( $this->builder->get_table() ) {
682
+		if ($this->builder->get_table()) {
683 683
 
684
-			if ( $this->parent_data['arg'] instanceof WordPoints_Entity_Relationship ) {
684
+			if ($this->parent_data['arg'] instanceof WordPoints_Entity_Relationship) {
685 685
 				$primary_field = $this->parent_data['storage_info']['meta']['field'];
686 686
 				$join_field = $db['id_field'];
687 687
 				//$primary_field = $this->arg_data['arg']->get_secondary_field();
688
-			} elseif ( $this->arg_data['arg'] instanceof WordPoints_Entity_Relationship ) {
688
+			} elseif ($this->arg_data['arg'] instanceof WordPoints_Entity_Relationship) {
689 689
 				$join_field = $db['join_field'];
690 690
 				$primary_field = $this->parent_data['storage_info']['meta']['id_field'];
691 691
 			} else {
692
-				throw new WordPoints_Query_Builder_Exception( 'Houston, we have a problem.' );
692
+				throw new WordPoints_Query_Builder_Exception('Houston, we have a problem.');
693 693
 			}
694 694
 
695
-			if ( is_array( $primary_field ) && isset( $primary_field['table_name'] ) ) {
696
-				$this->builder->enter_join( $primary_field );
695
+			if (is_array($primary_field) && isset($primary_field['table_name'])) {
696
+				$this->builder->enter_join($primary_field);
697 697
 				$primary_field = $primary_field['on']['join_field'];
698 698
 			}
699 699
 
@@ -705,26 +705,26 @@  discard block
 block discarded – undo
705 705
 				),
706 706
 			);
707 707
 
708
-			if ( isset( $db['join_where'] ) ) {
708
+			if (isset($db['join_where'])) {
709 709
 				$join['where'] = $db['join_where'];
710 710
 			}
711 711
 
712
-			$this->builder->enter_join( $join );
712
+			$this->builder->enter_join($join);
713 713
 
714 714
 			$this->entered_join = true;
715 715
 
716 716
 		} else {
717
-			$this->builder->set_table( $db['table_name'] );
718
-			$this->builder->add_field( $db['id_field'] );
717
+			$this->builder->set_table($db['table_name']);
718
+			$this->builder->add_field($db['id_field']);
719 719
 		}
720 720
 	}
721 721
 
722
-	protected function build_conditions( $conditions ) {
722
+	protected function build_conditions($conditions) {
723 723
 
724 724
 		// Join conditions should be pushed to the end.
725 725
 		$join_conditions = array();
726 726
 
727
-		foreach ( $conditions as $condition ) {
727
+		foreach ($conditions as $condition) {
728 728
 
729 729
 			// THis needs to be the identifier field for the type of arg that this
730 730
 			// field represents.
@@ -732,43 +732,43 @@  discard block
 block discarded – undo
732 732
 			// However, for a relationship it could be something else.
733 733
 			// Ultimately, this will have to be left up to the arg object to
734 734
 			// decide.
735
-			if ( ! isset( $condition['field'] ) ) {
736
-				if ( $this->arg_data['arg'] instanceof WordPoints_Entity_Relationship ) {
735
+			if ( ! isset($condition['field'])) {
736
+				if ($this->arg_data['arg'] instanceof WordPoints_Entity_Relationship) {
737 737
 //					$condition['field'] = $this->arg_data['arg']->get_secondary_field();
738 738
 					$condition['field'] = $this->arg_data['storage_info']['meta']['field'];
739 739
 
740
-					if ( is_array( $condition['field'] && isset( $condition['field']['table_name'] ) ) ) {
740
+					if (is_array($condition['field'] && isset($condition['field']['table_name']))) {
741 741
 						$join_conditions[] = $condition;
742 742
 						continue;
743 743
 					}
744
-				} elseif ( $this->arg_data['arg'] instanceof WordPoints_Entity_Attr ) {
744
+				} elseif ($this->arg_data['arg'] instanceof WordPoints_Entity_Attr) {
745 745
 					$condition['field'] = $this->arg_data['arg']->get_field();
746 746
 				} else {
747
-					var_dump($this->arg_data['arg']);exit;
747
+					var_dump($this->arg_data['arg']); exit;
748 748
 				}
749 749
 			}
750 750
 
751
-			$this->builder->where( $condition );
751
+			$this->builder->where($condition);
752 752
 		}
753 753
 
754
-		$join_count = count( $join_conditions );
754
+		$join_count = count($join_conditions);
755 755
 		$i = 0;
756 756
 
757
-		foreach ( $join_conditions as $condition ) {
757
+		foreach ($join_conditions as $condition) {
758 758
 
759 759
 			$i++;
760 760
 
761
-			$this->builder->enter_join( $condition['field'] );
761
+			$this->builder->enter_join($condition['field']);
762 762
 
763 763
 			$condition['field'] = $condition['field']['on']['primary_field'];
764 764
 
765
-			$this->builder->where( $condition );
765
+			$this->builder->where($condition);
766 766
 
767 767
 			$this->builder->exit_join();
768 768
 
769 769
 			// If there are more join conditions, we need to leave a fresh, trailing
770 770
 			// join for the next one to join to.
771
-			if ( $i < $join_count ) {
771
+			if ($i < $join_count) {
772 772
 
773 773
 				// There is a current join, but it is already being used, so we
774 774
 				// need to exit it.
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 }
785 785
 
786 786
 
787
-wordpoints_hooks()->retroactive_query_executors->register( 'db', 'WordPoints_Hook_Retroactive_Query_Executor_MySQL' );
787
+wordpoints_hooks()->retroactive_query_executors->register('db', 'WordPoints_Hook_Retroactive_Query_Executor_MySQL');
788 788
 
789 789
 
790 790
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/reactor/points.php 1 patch
Spacing   +37 added lines, -37 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 $hit_types = array( 'award', 'reverse' );
30
+	protected $hit_types = array('award', 'reverse');
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,12 +114,12 @@  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
 	/**
@@ -129,31 +129,31 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @param WordPoints_Hook_Fire $fire The hook fire object.
131 131
 	 */
132
-	protected function award( WordPoints_Hook_Fire $fire ) {
132
+	protected function award(WordPoints_Hook_Fire $fire) {
133 133
 
134 134
 		$reaction = $fire->reaction;
135 135
 
136 136
 		$target = $fire->event_args->get_from_hierarchy(
137
-			$reaction->get_meta( 'target' )
137
+			$reaction->get_meta('target')
138 138
 		);
139 139
 
140
-		if ( ! $target instanceof WordPoints_Entity ) {
140
+		if ( ! $target instanceof WordPoints_Entity) {
141 141
 			return;
142 142
 		}
143 143
 
144 144
 		$meta = array();
145 145
 
146
-		foreach ( $fire->event_args->get_entities() as $entity ) {
147
-			$meta[ $entity->get_slug() ] = $entity->get_the_id();
146
+		foreach ($fire->event_args->get_entities() as $entity) {
147
+			$meta[$entity->get_slug()] = $entity->get_the_id();
148 148
 		}
149 149
 
150 150
 		wordpoints_alter_points(
151 151
 			$target->get_the_id()
152
-			, $reaction->get_meta( 'points' )
153
-			, $reaction->get_meta( 'points_type' )
152
+			, $reaction->get_meta('points')
153
+			, $reaction->get_meta('points_type')
154 154
 			, $reaction->get_event_slug()
155 155
 			, $meta
156
-			, $reaction->get_meta( 'log_text' )
156
+			, $reaction->get_meta('log_text')
157 157
 		);
158 158
 	}
159 159
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @param WordPoints_Hook_Fire $fire The fire object.
166 166
 	 */
167
-	protected function reverse( WordPoints_Hook_Fire $fire ) {
167
+	protected function reverse(WordPoints_Hook_Fire $fire) {
168 168
 
169 169
 		$meta_queries = array(
170 170
 			array(
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 			),
176 176
 		);
177 177
 
178
-		foreach ( $fire->event_args->get_entities() as $slug => $entity ) {
178
+		foreach ($fire->event_args->get_entities() as $slug => $entity) {
179 179
 
180 180
 			$meta_queries[] = array(
181 181
 				'key'   => $slug,
@@ -192,35 +192,35 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$logs = $query->get();
194 194
 
195
-		if ( ! $logs ) {
195
+		if ( ! $logs) {
196 196
 			return;
197 197
 		}
198 198
 
199 199
 		global $wpdb;
200 200
 
201
-		add_filter( 'wordpoints_points_log', '__return_false' );
201
+		add_filter('wordpoints_points_log', '__return_false');
202 202
 
203
-		foreach ( $logs as $log ) {
203
+		foreach ($logs as $log) {
204 204
 
205 205
 			wordpoints_alter_points(
206 206
 				$log->user_id
207 207
 				, -$log->points
208 208
 				, $log->points_type
209 209
 				, "reverse-{$log->log_type}"
210
-				, array( 'original_log_id' => $log->id )
210
+				, array('original_log_id' => $log->id)
211 211
 			);
212 212
 
213
-			wordpoints_points_log_delete_all_metadata( $log->id );
213
+			wordpoints_points_log_delete_all_metadata($log->id);
214 214
 
215 215
 			// Now delete the log.
216 216
 			$wpdb->delete(
217 217
 				$wpdb->wordpoints_points_logs
218
-				, array( 'id' => $log->id )
218
+				, array('id' => $log->id)
219 219
 				, '%d'
220 220
 			); // WPCS: cache OK, cleaned by wordpoints_alter_points().
221 221
 		}
222 222
 
223
-		remove_filter( 'wordpoints_points_log', '__return_false' );
223
+		remove_filter('wordpoints_points_log', '__return_false');
224 224
 	}
225 225
 }
226 226
 
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction/store.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * @since 1.0.0
53 53
 	 */
54
-	public function __construct( $slug ) {
54
+	public function __construct($slug) {
55 55
 		$this->slug = $slug;
56 56
 	}
57 57
 
@@ -66,33 +66,33 @@  discard block
 block discarded – undo
66 66
 	 * @since 1.0.0
67 67
 	 */
68 68
 	public function get_context_id() {
69
-		return wordpoints_entities_get_current_context_id( $this->context );
69
+		return wordpoints_entities_get_current_context_id($this->context);
70 70
 	}
71 71
 
72 72
 	/**
73 73
 	 * @since 1.0.0
74 74
 	 */
75
-	public function get_reaction( $id ) {
75
+	public function get_reaction($id) {
76 76
 
77
-		if ( ! $this->reaction_exists( $id ) ) {
77
+		if ( ! $this->reaction_exists($id)) {
78 78
 			return false;
79 79
 		}
80 80
 
81
-		return new $this->reaction_class( $id, $this );
81
+		return new $this->reaction_class($id, $this);
82 82
 	}
83 83
 
84 84
 	/**
85 85
 	 * @since 1.0.0
86 86
 	 */
87
-	public function create_reaction( array $settings ) {
88
-		return $this->create_or_update_reaction( $settings );
87
+	public function create_reaction(array $settings) {
88
+		return $this->create_or_update_reaction($settings);
89 89
 	}
90 90
 
91 91
 	/**
92 92
 	 * @since 1.0.0
93 93
 	 */
94
-	public function update_reaction( $id, array $settings ) {
95
-		return $this->create_or_update_reaction( $settings, $id );
94
+	public function update_reaction($id, array $settings) {
95
+		return $this->create_or_update_reaction($settings, $id);
96 96
 	}
97 97
 
98 98
 	/**
@@ -107,45 +107,45 @@  discard block
 block discarded – undo
107 107
 	 *         The reaction object if created/updated successfully. False or a
108 108
 	 *         validator instance if not.
109 109
 	 */
110
-	protected function create_or_update_reaction( array $settings, $id = null ) {
110
+	protected function create_or_update_reaction(array $settings, $id = null) {
111 111
 
112
-		$is_new = ! isset( $id );
112
+		$is_new = ! isset($id);
113 113
 
114
-		if ( ! $is_new && ! $this->reaction_exists( $id ) ) {
114
+		if ( ! $is_new && ! $this->reaction_exists($id)) {
115 115
 			return false;
116 116
 		}
117 117
 
118
-		$validator = new WordPoints_Hook_Reaction_Validator( $settings );
118
+		$validator = new WordPoints_Hook_Reaction_Validator($settings);
119 119
 		$settings = $validator->validate();
120 120
 
121
-		if ( $validator->had_errors() ) {
121
+		if ($validator->had_errors()) {
122 122
 			return $validator;
123 123
 		}
124 124
 
125
-		if ( $is_new ) {
125
+		if ($is_new) {
126 126
 
127
-			$id = $this->_create_reaction( $settings['event'] );
127
+			$id = $this->_create_reaction($settings['event']);
128 128
 
129
-			if ( ! $id ) {
129
+			if ( ! $id) {
130 130
 				return false;
131 131
 			}
132 132
 		}
133 133
 
134
-		$reaction = $this->get_reaction( $id );
134
+		$reaction = $this->get_reaction($id);
135 135
 
136
-		$reaction->update_event_slug( $settings['event'] );
136
+		$reaction->update_event_slug($settings['event']);
137 137
 
138
-		unset( $settings['event'] );
138
+		unset($settings['event']);
139 139
 
140
-		$reaction->update_meta( 'reactor', $settings['reactor'] );
140
+		$reaction->update_meta('reactor', $settings['reactor']);
141 141
 
142 142
 		/** @var WordPoints_Hook_Reactor $reactor */
143
-		$reactor = wordpoints_hooks()->reactors->get( $settings['reactor'] );
144
-		$reactor->update_settings( $reaction, $settings );
143
+		$reactor = wordpoints_hooks()->reactors->get($settings['reactor']);
144
+		$reactor->update_settings($reaction, $settings);
145 145
 
146 146
 		/** @var WordPoints_Hook_Extension $extension */
147
-		foreach ( wordpoints_hooks()->extensions->get_all() as $extension ) {
148
-			$extension->update_settings( $reaction, $settings );
147
+		foreach (wordpoints_hooks()->extensions->get_all() as $extension) {
148
+			$extension->update_settings($reaction, $settings);
149 149
 		}
150 150
 
151 151
 		/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		 * @param array                     $settings The new settings for the reaction.
156 156
 		 * @param bool                      $is_new   Whether the reaction was just now created.
157 157
 		 */
158
-		do_action( 'wordpoints_hook_reaction_save', $reaction, $settings, $is_new );
158
+		do_action('wordpoints_hook_reaction_save', $reaction, $settings, $is_new);
159 159
 
160 160
 		return $reaction;
161 161
 	}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return int|false The reaction ID, or false if not created.
174 174
 	 */
175
-	abstract protected function _create_reaction( $event_slug );
175
+	abstract protected function _create_reaction($event_slug);
176 176
 }
177 177
 
178 178
 // EOF
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction/validator.php 1 patch
Spacing   +32 added lines, -32 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,16 +146,16 @@  discard block
 block discarded – undo
146 146
 			$fail_fast = $this->fail_fast;
147 147
 			$this->fail_fast = true;
148 148
 
149
-			if ( ! isset( $this->event_slug ) ) {
150
-				$this->add_error( __( 'Event is missing.', 'wordpoints' ), 'event' );
151
-			} elseif ( ! $this->hooks->events->is_registered( $this->event_slug ) ) {
152
-				$this->add_error( __( 'Event is invalid.', 'wordpoints' ), 'event' );
149
+			if ( ! isset($this->event_slug)) {
150
+				$this->add_error(__('Event is missing.', 'wordpoints'), 'event');
151
+			} elseif ( ! $this->hooks->events->is_registered($this->event_slug)) {
152
+				$this->add_error(__('Event is invalid.', 'wordpoints'), 'event');
153 153
 			}
154 154
 
155
-			if ( ! isset( $this->reactor_slug ) ) {
156
-				$this->add_error( __( 'Reactor is missing.', 'wordpoints' ), 'reactor' );
157
-			} elseif ( ! $this->hooks->reactors->is_registered( $this->reactor_slug ) ) {
158
-				$this->add_error( __( 'Reactor is invalid.', 'wordpoints' ), 'reactor' );
155
+			if ( ! isset($this->reactor_slug)) {
156
+				$this->add_error(__('Reactor is missing.', 'wordpoints'), 'reactor');
157
+			} elseif ( ! $this->hooks->reactors->is_registered($this->reactor_slug)) {
158
+				$this->add_error(__('Reactor is invalid.', 'wordpoints'), 'reactor');
159 159
 			}
160 160
 
161 161
 			// From here on out we can collect errors as they come (unless we are
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 				$this->event_slug
167 167
 			);
168 168
 
169
-			$this->event_args = new WordPoints_Hook_Event_Args( $event_args );
170
-			$this->event_args->set_validator( $this );
169
+			$this->event_args = new WordPoints_Hook_Event_Args($event_args);
170
+			$this->event_args->set_validator($this);
171 171
 
172
-			$reactor = $this->hooks->reactors->get( $this->reactor_slug );
172
+			$reactor = $this->hooks->reactors->get($this->reactor_slug);
173 173
 
174
-			$this->settings = $reactor->validate_settings( $this->settings, $this, $this->event_args );
174
+			$this->settings = $reactor->validate_settings($this->settings, $this, $this->event_args);
175 175
 
176 176
 			/** @var WordPoints_Hook_Extension $extension */
177
-			foreach ( $this->hooks->extensions->get_all() as $extension ) {
178
-				$this->settings = $extension->validate_settings( $this->settings, $this, $this->event_args );
177
+			foreach ($this->hooks->extensions->get_all() as $extension) {
178
+				$this->settings = $extension->validate_settings($this->settings, $this, $this->event_args);
179 179
 			}
180 180
 
181 181
 			/**
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 			 * @param WordPoints_Hook_Reaction_Validator $validator The validator object.
186 186
 			 * @param WordPoints_Hook_Event_Args         $args      The event args object.
187 187
 			 */
188
-			$this->settings = apply_filters( 'wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args );
188
+			$this->settings = apply_filters('wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args);
189 189
 
190
-		} catch ( WordPoints_Hook_Validator_Exception $e ) {
190
+		} catch (WordPoints_Hook_Validator_Exception $e) {
191 191
 
192 192
 			// Do nothing.
193
-			unset( $e );
193
+			unset($e);
194 194
 		}
195 195
 
196 196
 		return $this->settings;
@@ -218,17 +218,17 @@  discard block
 block discarded – undo
218 218
 	 * @throws WordPoints_Hook_Validator_Exception If the validator is configured to
219 219
 	 *                                             fail as soon as an error is found.
220 220
 	 */
221
-	public function add_error( $message, $field = null ) {
221
+	public function add_error($message, $field = null) {
222 222
 
223 223
 		$field_stack = $this->field_stack;
224 224
 
225
-		if ( null !== $field ) {
225
+		if (null !== $field) {
226 226
 			$field_stack[] = $field;
227 227
 		}
228 228
 
229
-		$this->errors[] = array( 'message' => $message, 'field' => $field_stack );
229
+		$this->errors[] = array('message' => $message, 'field' => $field_stack);
230 230
 
231
-		if ( $this->fail_fast ) {
231
+		if ($this->fail_fast) {
232 232
 			throw new WordPoints_Hook_Validator_Exception;
233 233
 		}
234 234
 	}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 * @return bool Whether the validator found any errors.
242 242
 	 */
243 243
 	public function had_errors() {
244
-		return ! empty( $this->errors );
244
+		return ! empty($this->errors);
245 245
 	}
246 246
 
247 247
 	/**
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 *
263 263
 	 * @param string $field The field.
264 264
 	 */
265
-	public function push_field( $field ) {
265
+	public function push_field($field) {
266 266
 		$this->field_stack[] = $field;
267 267
 	}
268 268
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @since 1.0.0
273 273
 	 */
274 274
 	public function pop_field() {
275
-		array_pop( $this->field_stack );
275
+		array_pop($this->field_stack);
276 276
 	}
277 277
 
278 278
 	/**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 */
318 318
 	public function get_id() {
319 319
 
320
-		if ( ! $this->reaction ) {
320
+		if ( ! $this->reaction) {
321 321
 			return false;
322 322
 		}
323 323
 
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @return mixed The meta value.
357 357
 	 */
358
-	public function get_meta( $key ) {
358
+	public function get_meta($key) {
359 359
 
360
-		if ( ! isset( $this->settings[ $key ] ) ) {
360
+		if ( ! isset($this->settings[$key])) {
361 361
 			return null;
362 362
 		}
363 363
 
364
-		return $this->settings[ $key ];
364
+		return $this->settings[$key];
365 365
 	}
366 366
 
367 367
 	/**
Please login to merge, or discard this patch.
src/includes/classes/hook/reaction/storei.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @param string $slug The slug of this store.
26 26
 	 */
27
-	public function __construct( $slug );
27
+	public function __construct($slug);
28 28
 
29 29
 	/**
30 30
 	 * Get the slug of this reaction store.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return bool Whether the reaction exists.
61 61
 	 */
62
-	public function reaction_exists( $id );
62
+	public function reaction_exists($id);
63 63
 
64 64
 	/**
65 65
 	 * Get an reaction object.
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return WordPoints_Hook_ReactionI|false The reaction, or false if nonexistent.
72 72
 	 */
73
-	public function get_reaction( $id );
73
+	public function get_reaction($id);
74 74
 
75 75
 	/**
76 76
 	 * Create an reaction.
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 *         The reaction object if created successfully. False or a validator
84 84
 	 *         instance if not.
85 85
 	 */
86
-	public function create_reaction( array $settings );
86
+	public function create_reaction(array $settings);
87 87
 
88 88
 	/**
89 89
 	 * Update an reaction.
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *         The reaction object if updated successfully. False or a validator
98 98
 	 *         instance if not.
99 99
 	 */
100
-	public function update_reaction( $id, array $settings );
100
+	public function update_reaction($id, array $settings);
101 101
 
102 102
 	/**
103 103
 	 * Delete an reaction.
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return bool Whether the reaction was deleted successfully.
110 110
 	 */
111
-	public function delete_reaction( $id );
111
+	public function delete_reaction($id);
112 112
 
113 113
 	/**
114 114
 	 * Get all hook reactions for the reactor.
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return WordPoints_Hook_ReactionI[]
133 133
 	 */
134
-	public function get_reactions_to_event( $event_slug );
134
+	public function get_reactions_to_event($event_slug);
135 135
 }
136 136
 
137 137
 // EOF
Please login to merge, or discard this patch.