Completed
Push — master ( e7ef90...760553 )
by J.D.
03:28
created
src/classes/data/type/text.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@
 block discarded – undo
20 20
 	/**
21 21
 	 * @since 2.1.0
22 22
 	 */
23
-	public function validate_value( $value ) {
23
+	public function validate_value($value) {
24 24
 
25
-		if ( ! is_string( $value ) ) {
25
+		if ( ! is_string($value)) {
26 26
 			return new WP_Error(
27 27
 				'not_string'
28
-				, __( '%s must be a text value.', 'wordpoints' )
28
+				, __('%s must be a text value.', 'wordpoints')
29 29
 			);
30 30
 		}
31 31
 
Please login to merge, or discard this patch.
src/classes/hook/reactori.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 	 *
77 77
 	 * @param WordPoints_Hook_Fire $fire The hook fire object.
78 78
 	 */
79
-	public function hit( WordPoints_Hook_Fire $fire );
79
+	public function hit(WordPoints_Hook_Fire $fire);
80 80
 }
81 81
 
82 82
 // EOF
Please login to merge, or discard this patch.
src/classes/hook/router.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	/**
90 90
 	 * @since 2.1.0
91 91
 	 */
92
-	public function __call( $name, $args ) {
92
+	public function __call($name, $args) {
93 93
 
94
-		$this->route_action( $name, $args );
94
+		$this->route_action($name, $args);
95 95
 
96 96
 		// Return the first value, in case it is hooked to a filter.
97 97
 		$return = null;
98
-		if ( isset( $args[0] ) ) {
98
+		if (isset($args[0])) {
99 99
 			$return = $args[0];
100 100
 		}
101 101
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 	 *                     action name and the priority.
113 113
 	 * @param array  $args The args the action was fired with.
114 114
 	 */
115
-	protected function route_action( $name, $args ) {
115
+	protected function route_action($name, $args) {
116 116
 
117
-		if ( ! isset( $this->action_index[ $name ] ) ) {
117
+		if ( ! isset($this->action_index[$name])) {
118 118
 			return;
119 119
 		}
120 120
 
@@ -122,48 +122,48 @@  discard block
 block discarded – undo
122 122
 		// registry attempts to access the router in its own constructor. The result
123 123
 		// of attempting to do this before the router itself has been fully
124 124
 		// constructed is that the events registry gets null instead of the router.
125
-		if ( ! isset( $this->hooks ) ) {
125
+		if ( ! isset($this->hooks)) {
126 126
 
127 127
 			$hooks = wordpoints_hooks();
128 128
 
129 129
 			$this->hooks   = $hooks;
130
-			$this->events  = $hooks->get_sub_app( 'events' );
131
-			$this->actions = $hooks->get_sub_app( 'actions' );
132
-			$this->event_args = $this->events->get_sub_app( 'args' );
130
+			$this->events  = $hooks->get_sub_app('events');
131
+			$this->actions = $hooks->get_sub_app('actions');
132
+			$this->event_args = $this->events->get_sub_app('args');
133 133
 		}
134 134
 
135
-		foreach ( $this->action_index[ $name ]['actions'] as $slug => $data ) {
135
+		foreach ($this->action_index[$name]['actions'] as $slug => $data) {
136 136
 
137
-			if ( ! isset( $this->event_index[ $slug ] ) ) {
137
+			if ( ! isset($this->event_index[$slug])) {
138 138
 				continue;
139 139
 			}
140 140
 
141
-			$action_object = $this->actions->get( $slug, $args, $data );
141
+			$action_object = $this->actions->get($slug, $args, $data);
142 142
 
143
-			if ( ! ( $action_object instanceof WordPoints_Hook_ActionI ) ) {
143
+			if ( ! ($action_object instanceof WordPoints_Hook_ActionI)) {
144 144
 				continue;
145 145
 			}
146 146
 
147
-			if ( ! $action_object->should_fire() ) {
147
+			if ( ! $action_object->should_fire()) {
148 148
 				continue;
149 149
 			}
150 150
 
151
-			foreach ( $this->event_index[ $slug ] as $type => $events ) {
152
-				foreach ( $events as $event_slug => $unused ) {
151
+			foreach ($this->event_index[$slug] as $type => $events) {
152
+				foreach ($events as $event_slug => $unused) {
153 153
 
154
-					if ( ! $this->events->is_registered( $event_slug ) ) {
154
+					if ( ! $this->events->is_registered($event_slug)) {
155 155
 						continue;
156 156
 					}
157 157
 
158
-					$event_args = $this->event_args->get_children( $event_slug, array( $action_object ) );
158
+					$event_args = $this->event_args->get_children($event_slug, array($action_object));
159 159
 
160
-					if ( empty( $event_args ) ) {
160
+					if (empty($event_args)) {
161 161
 						continue;
162 162
 					}
163 163
 
164
-					$event_args = new WordPoints_Hook_Event_Args( $event_args );
164
+					$event_args = new WordPoints_Hook_Event_Args($event_args);
165 165
 
166
-					$this->hooks->fire( $event_slug, $event_args, $type );
166
+					$this->hooks->fire($event_slug, $event_args, $type);
167 167
 				}
168 168
 			}
169 169
 		}
@@ -192,56 +192,56 @@  discard block
 block discarded – undo
192 192
 	 *        }
193 193
 	 * }
194 194
 	 */
195
-	public function add_action( $slug, array $args ) {
195
+	public function add_action($slug, array $args) {
196 196
 
197 197
 		$priority = 10;
198
-		if ( isset( $args['priority'] ) ) {
198
+		if (isset($args['priority'])) {
199 199
 			$priority = $args['priority'];
200 200
 		}
201 201
 
202
-		if ( ! isset( $args['action'] ) ) {
202
+		if ( ! isset($args['action'])) {
203 203
 			return;
204 204
 		}
205 205
 
206 206
 		$method = "{$args['action']},{$priority}";
207 207
 
208
-		$this->action_index[ $method ]['actions'][ $slug ] = array();
208
+		$this->action_index[$method]['actions'][$slug] = array();
209 209
 
210 210
 		$arg_number = 1;
211 211
 
212
-		if ( isset( $args['data'] ) ) {
212
+		if (isset($args['data'])) {
213 213
 
214
-			if ( isset( $args['data']['arg_index'] ) ) {
215
-				$arg_number = 1 + max( $args['data']['arg_index'] );
214
+			if (isset($args['data']['arg_index'])) {
215
+				$arg_number = 1 + max($args['data']['arg_index']);
216 216
 			}
217 217
 
218
-			if ( isset( $args['data']['requirements'] ) ) {
219
-				$requirements = 1 + max( array_keys( $args['data']['requirements'] ) );
218
+			if (isset($args['data']['requirements'])) {
219
+				$requirements = 1 + max(array_keys($args['data']['requirements']));
220 220
 
221
-				if ( $requirements > $arg_number ) {
221
+				if ($requirements > $arg_number) {
222 222
 					$arg_number = $requirements;
223 223
 				}
224 224
 			}
225 225
 
226
-			$this->action_index[ $method ]['actions'][ $slug ] = $args['data'];
226
+			$this->action_index[$method]['actions'][$slug] = $args['data'];
227 227
 		}
228 228
 
229
-		if ( isset( $args['arg_number'] ) ) {
229
+		if (isset($args['arg_number'])) {
230 230
 			$arg_number = $args['arg_number'];
231 231
 		}
232 232
 
233 233
 		// If this action is already being routed, and will have enough args, we
234 234
 		// don't need to hook to it again.
235 235
 		if (
236
-			isset( $this->action_index[ $method ]['arg_number'] )
237
-			&& $this->action_index[ $method ]['arg_number'] >= $arg_number
236
+			isset($this->action_index[$method]['arg_number'])
237
+			&& $this->action_index[$method]['arg_number'] >= $arg_number
238 238
 		) {
239 239
 			return;
240 240
 		}
241 241
 
242
-		$this->action_index[ $method ]['arg_number'] = $arg_number;
242
+		$this->action_index[$method]['arg_number'] = $arg_number;
243 243
 
244
-		add_action( $args['action'], array( $this, $method ), $priority, $arg_number );
244
+		add_action($args['action'], array($this, $method), $priority, $arg_number);
245 245
 	}
246 246
 
247 247
 	/**
@@ -251,20 +251,20 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @param string $slug The action slug.
253 253
 	 */
254
-	public function remove_action( $slug ) {
254
+	public function remove_action($slug) {
255 255
 
256
-		foreach ( $this->action_index as $method => $data ) {
257
-			if ( isset( $data['actions'][ $slug ] ) ) {
256
+		foreach ($this->action_index as $method => $data) {
257
+			if (isset($data['actions'][$slug])) {
258 258
 
259
-				unset( $this->action_index[ $method ]['actions'][ $slug ] );
259
+				unset($this->action_index[$method]['actions'][$slug]);
260 260
 
261
-				if ( empty( $this->action_index[ $method ]['actions'] ) ) {
261
+				if (empty($this->action_index[$method]['actions'])) {
262 262
 
263
-					unset( $this->action_index[ $method ] );
263
+					unset($this->action_index[$method]);
264 264
 
265
-					list( $action, $priority ) = explode( ',', $method );
265
+					list($action, $priority) = explode(',', $method);
266 266
 
267
-					remove_action( $action, array( $this, $method ), $priority );
267
+					remove_action($action, array($this, $method), $priority);
268 268
 				}
269 269
 			}
270 270
 		}
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @param string $action_slug The slug of the action.
280 280
 	 * @param string $action_type The type of action. Default is 'fire'.
281 281
 	 */
282
-	public function add_event_to_action( $event_slug, $action_slug, $action_type = 'fire' ) {
283
-		$this->event_index[ $action_slug ][ $action_type ][ $event_slug ] = true;
282
+	public function add_event_to_action($event_slug, $action_slug, $action_type = 'fire') {
283
+		$this->event_index[$action_slug][$action_type][$event_slug] = true;
284 284
 	}
285 285
 
286 286
 	/**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param string $action_slug The slug of the action.
293 293
 	 * @param string $action_type The type of action. Default is 'fire'.
294 294
 	 */
295
-	public function remove_event_from_action( $event_slug, $action_slug, $action_type = 'fire' ) {
296
-		unset( $this->event_index[ $action_slug ][ $action_type ][ $event_slug ] );
295
+	public function remove_event_from_action($event_slug, $action_slug, $action_type = 'fire') {
296
+		unset($this->event_index[$action_slug][$action_type][$event_slug]);
297 297
 	}
298 298
 
299 299
 	/**
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 	 */
306 306
 	public function get_event_index() {
307 307
 
308
-		if ( empty( $this->event_index ) ) {
309
-			wordpoints_hooks()->get_sub_app( 'events' );
308
+		if (empty($this->event_index)) {
309
+			wordpoints_hooks()->get_sub_app('events');
310 310
 		}
311 311
 
312 312
 		return $this->event_index;
Please login to merge, or discard this patch.
src/classes/hook/extension.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 		WordPoints_Hook_Event_Args $event_args
58 58
 	) {
59 59
 
60
-		if ( ! isset( $settings[ $this->slug ] ) ) {
60
+		if ( ! isset($settings[$this->slug])) {
61 61
 			return $settings;
62 62
 		}
63 63
 
64
-		if ( ! is_array( $settings[ $this->slug ] ) ) {
64
+		if ( ! is_array($settings[$this->slug])) {
65 65
 
66 66
 			$validator->add_error(
67
-				__( 'Invalid settings format.', 'wordpoints' )
67
+				__('Invalid settings format.', 'wordpoints')
68 68
 				, $this->slug
69 69
 			);
70 70
 
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 		$this->validator = $validator;
75 75
 		$this->event_args = $event_args;
76 76
 
77
-		$this->validator->push_field( $this->slug );
77
+		$this->validator->push_field($this->slug);
78 78
 
79
-		foreach ( $settings[ $this->slug ] as $action_type => $action_type_settings ) {
79
+		foreach ($settings[$this->slug] as $action_type => $action_type_settings) {
80 80
 
81
-			$this->validator->push_field( $action_type );
81
+			$this->validator->push_field($action_type);
82 82
 
83
-			$settings[ $this->slug ][ $action_type ] = $this->validate_action_type_settings(
83
+			$settings[$this->slug][$action_type] = $this->validate_action_type_settings(
84 84
 				$action_type_settings
85 85
 			);
86 86
 
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 	/**
96 96
 	 * @since 2.1.0
97 97
 	 */
98
-	public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) {
98
+	public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) {
99 99
 
100
-		if ( isset( $settings[ $this->slug ] ) ) {
101
-			$reaction->update_meta( $this->slug, $settings[ $this->slug ] );
100
+		if (isset($settings[$this->slug])) {
101
+			$reaction->update_meta($this->slug, $settings[$this->slug]);
102 102
 		} else {
103
-			$reaction->delete_meta( $this->slug );
103
+			$reaction->delete_meta($this->slug);
104 104
 		}
105 105
 	}
106 106
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return mixed The validated settings.
115 115
 	 */
116
-	protected function validate_action_type_settings( $settings ) {
116
+	protected function validate_action_type_settings($settings) {
117 117
 		return $settings;
118 118
 	}
119 119
 
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @return mixed The settings for the extension, or false if none.
132 132
 	 */
133
-	protected function get_settings_from_fire( WordPoints_Hook_Fire $fire ) {
133
+	protected function get_settings_from_fire(WordPoints_Hook_Fire $fire) {
134 134
 
135
-		$settings = $fire->reaction->get_meta( $this->slug );
135
+		$settings = $fire->reaction->get_meta($this->slug);
136 136
 
137
-		if ( ! is_array( $settings ) ) {
137
+		if ( ! is_array($settings)) {
138 138
 			return $settings;
139 139
 		}
140 140
 
141
-		if ( isset( $settings[ $fire->action_type ] ) ) {
142
-			return $settings[ $fire->action_type ];
141
+		if (isset($settings[$fire->action_type])) {
142
+			return $settings[$fire->action_type];
143 143
 		} else {
144 144
 			return false;
145 145
 		}
Please login to merge, or discard this patch.
src/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 2.1.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 2.1.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 2.1.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/classes/hook/extension/blocker.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
 	/**
25 25
 	 * @since 2.1.0
26 26
 	 */
27
-	public function validate_action_type_settings( $settings ) {
27
+	public function validate_action_type_settings($settings) {
28 28
 		return (bool) $settings;
29 29
 	}
30 30
 
31 31
 	/**
32 32
 	 * @since 2.1.0
33 33
 	 */
34
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
35
-		return ! $this->get_settings_from_fire( $fire );
34
+	public function should_hit(WordPoints_Hook_Fire $fire) {
35
+		return ! $this->get_settings_from_fire($fire);
36 36
 	}
37 37
 }
38 38
 
Please login to merge, or discard this patch.
src/classes/hook/extension/periods.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 	public function get_ui_script_data() {
40 40
 
41 41
 		$period_units = array(
42
-			1                   => __( 'Seconds', 'wordpoints' ),
43
-			MINUTE_IN_SECONDS   => __( 'Minutes', 'wordpoints' ),
44
-			HOUR_IN_SECONDS     => __( 'Hours',   'wordpoints' ),
45
-			DAY_IN_SECONDS      => __( 'Days',    'wordpoints' ),
46
-			WEEK_IN_SECONDS     => __( 'Weeks',   'wordpoints' ),
47
-			30 * DAY_IN_SECONDS => __( 'Months',  'wordpoints' ),
42
+			1                   => __('Seconds', 'wordpoints'),
43
+			MINUTE_IN_SECONDS   => __('Minutes', 'wordpoints'),
44
+			HOUR_IN_SECONDS     => __('Hours', 'wordpoints'),
45
+			DAY_IN_SECONDS      => __('Days', 'wordpoints'),
46
+			WEEK_IN_SECONDS     => __('Weeks', 'wordpoints'),
47
+			30 * DAY_IN_SECONDS => __('Months', 'wordpoints'),
48 48
 		);
49 49
 
50 50
 		/**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		return array(
63 63
 			'period_units' => $period_units,
64 64
 			'l10n' => array(
65
-				'label' => __( 'Trigger reaction no more than once in:', 'wordpoints' ),
65
+				'label' => __('Trigger reaction no more than once in:', 'wordpoints'),
66 66
 			),
67 67
 		);
68 68
 	}
@@ -76,25 +76,25 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return array The validated periods.
78 78
 	 */
79
-	protected function validate_action_type_settings( $periods ) {
79
+	protected function validate_action_type_settings($periods) {
80 80
 
81
-		if ( ! is_array( $periods ) ) {
81
+		if ( ! is_array($periods)) {
82 82
 
83 83
 			$this->validator->add_error(
84
-				__( 'Periods do not match expected format.', 'wordpoints' )
84
+				__('Periods do not match expected format.', 'wordpoints')
85 85
 			);
86 86
 
87 87
 			return array();
88 88
 		}
89 89
 
90
-		foreach ( $periods as $index => $period ) {
90
+		foreach ($periods as $index => $period) {
91 91
 
92
-			$this->validator->push_field( $index );
92
+			$this->validator->push_field($index);
93 93
 
94
-			$period = $this->validate_period( $period );
94
+			$period = $this->validate_period($period);
95 95
 
96
-			if ( $period ) {
97
-				$periods[ $index ] = $period;
96
+			if ($period) {
97
+				$periods[$index] = $period;
98 98
 			}
99 99
 
100 100
 			$this->validator->pop_field();
@@ -112,30 +112,30 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return array|false The validated period, or false if invalid.
114 114
 	 */
115
-	protected function validate_period( $period ) {
115
+	protected function validate_period($period) {
116 116
 
117
-		if ( ! is_array( $period ) ) {
117
+		if ( ! is_array($period)) {
118 118
 			$this->validator->add_error(
119
-				__( 'Period does not match expected format.', 'wordpoints' )
119
+				__('Period does not match expected format.', 'wordpoints')
120 120
 			);
121 121
 
122 122
 			return false;
123 123
 		}
124 124
 
125
-		if ( isset( $period['args'] ) ) {
126
-			$this->validate_period_args( $period['args'] );
125
+		if (isset($period['args'])) {
126
+			$this->validate_period_args($period['args']);
127 127
 		}
128 128
 
129
-		if ( ! isset( $period['length'] ) ) {
129
+		if ( ! isset($period['length'])) {
130 130
 
131 131
 			$this->validator->add_error(
132
-				__( 'Period length setting is missing.', 'wordpoints' )
132
+				__('Period length setting is missing.', 'wordpoints')
133 133
 			);
134 134
 
135
-		} elseif ( false === wordpoints_posint( $period['length'] ) ) {
135
+		} elseif (false === wordpoints_posint($period['length'])) {
136 136
 
137 137
 			$this->validator->add_error(
138
-				__( 'Period length must be a positive integer.', 'wordpoints' )
138
+				__('Period length must be a positive integer.', 'wordpoints')
139 139
 				, 'length'
140 140
 			);
141 141
 
@@ -152,34 +152,34 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @param mixed $args The args the period is related to.
154 154
 	 */
155
-	protected function validate_period_args( $args ) {
155
+	protected function validate_period_args($args) {
156 156
 
157
-		if ( ! is_array( $args ) ) {
157
+		if ( ! is_array($args)) {
158 158
 
159 159
 			$this->validator->add_error(
160
-				__( 'Period does not match expected format.', 'wordpoints' )
160
+				__('Period does not match expected format.', 'wordpoints')
161 161
 				, 'args'
162 162
 			);
163 163
 
164 164
 			return;
165 165
 		}
166 166
 
167
-		$this->validator->push_field( 'args' );
167
+		$this->validator->push_field('args');
168 168
 
169
-		foreach ( $args as $index => $hierarchy ) {
169
+		foreach ($args as $index => $hierarchy) {
170 170
 
171
-			$this->validator->push_field( $index );
171
+			$this->validator->push_field($index);
172 172
 
173
-			if ( ! is_array( $hierarchy ) ) {
173
+			if ( ! is_array($hierarchy)) {
174 174
 
175 175
 				$this->validator->add_error(
176
-					__( 'Period does not match expected format.', 'wordpoints' )
176
+					__('Period does not match expected format.', 'wordpoints')
177 177
 				);
178 178
 
179
-			} elseif ( ! $this->event_args->get_from_hierarchy( $hierarchy ) ) {
179
+			} elseif ( ! $this->event_args->get_from_hierarchy($hierarchy)) {
180 180
 
181 181
 				$this->validator->add_error(
182
-					__( 'Invalid arg hierarchy for period.', 'wordpoints' )
182
+					__('Invalid arg hierarchy for period.', 'wordpoints')
183 183
 				);
184 184
 			}
185 185
 
@@ -192,19 +192,19 @@  discard block
 block discarded – undo
192 192
 	/**
193 193
 	 * @since 2.1.0
194 194
 	 */
195
-	public function should_hit( WordPoints_Hook_Fire $fire ) {
195
+	public function should_hit(WordPoints_Hook_Fire $fire) {
196 196
 
197
-		$periods = $this->get_settings_from_fire( $fire );
197
+		$periods = $this->get_settings_from_fire($fire);
198 198
 
199
-		if ( empty( $periods ) ) {
199
+		if (empty($periods)) {
200 200
 			return true;
201 201
 		}
202 202
 
203 203
 		$this->event_args = $fire->event_args;
204 204
 		$this->action_type = $fire->action_type;
205 205
 
206
-		foreach ( $periods as $period ) {
207
-			if ( ! $this->has_period_ended( $period, $fire->reaction ) ) {
206
+		foreach ($periods as $period) {
207
+			if ( ! $this->has_period_ended($period, $fire->reaction)) {
208 208
 				return false;
209 209
 			}
210 210
 		}
@@ -227,27 +227,27 @@  discard block
 block discarded – undo
227 227
 		WordPoints_Hook_ReactionI $reaction
228 228
 	) {
229 229
 
230
-		$period = $this->get_period_by_reaction( $settings, $reaction );
230
+		$period = $this->get_period_by_reaction($settings, $reaction);
231 231
 
232 232
 		// If the period isn't found, we know that we can still fire.
233
-		if ( ! $period ) {
233
+		if ( ! $period) {
234 234
 			return true;
235 235
 		}
236 236
 
237
-		$now = current_time( 'timestamp', true );
238
-		$hit_time = strtotime( $period->date, $now );
237
+		$now = current_time('timestamp', true);
238
+		$hit_time = strtotime($period->date, $now);
239 239
 
240
-		if ( ! empty( $settings['relative'] ) ) {
240
+		if ( ! empty($settings['relative'])) {
241 241
 
242
-			return ( $now > $hit_time + $settings['length'] );
242
+			return ($now > $hit_time + $settings['length']);
243 243
 
244 244
 		} else {
245 245
 
246
-			$offset = get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
246
+			$offset = get_option('gmt_offset') * HOUR_IN_SECONDS;
247 247
 
248 248
 			return (
249
-				(int) ( ( $hit_time + $offset ) / $settings['length'] )
250
-				< (int) ( ( $now + $offset ) / $settings['length'] )
249
+				(int) (($hit_time + $offset) / $settings['length'])
250
+				< (int) (($now + $offset) / $settings['length'])
251 251
 			);
252 252
 		}
253 253
 	}
@@ -261,24 +261,24 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @return array The arg values.
263 263
 	 */
264
-	protected function get_arg_values( array $period_args ) {
264
+	protected function get_arg_values(array $period_args) {
265 265
 
266 266
 		$values = array();
267 267
 
268
-		foreach ( $period_args as $arg_hierarchy ) {
268
+		foreach ($period_args as $arg_hierarchy) {
269 269
 
270 270
 			$arg = $this->event_args->get_from_hierarchy(
271 271
 				$arg_hierarchy
272 272
 			);
273 273
 
274
-			if ( ! $arg instanceof WordPoints_EntityishI ) {
274
+			if ( ! $arg instanceof WordPoints_EntityishI) {
275 275
 				continue;
276 276
 			}
277 277
 
278
-			$values[ implode( '.', $arg_hierarchy ) ] = $arg->get_the_value();
278
+			$values[implode('.', $arg_hierarchy)] = $arg->get_the_value();
279 279
 		}
280 280
 
281
-		ksort( $values );
281
+		ksort($values);
282 282
 
283 283
 		return $values;
284 284
 	}
@@ -292,11 +292,11 @@  discard block
 block discarded – undo
292 292
 	 *
293 293
 	 * @return object|false The period data, or false if not found.
294 294
 	 */
295
-	protected function get_period( $period_id ) {
295
+	protected function get_period($period_id) {
296 296
 
297
-		$period = wp_cache_get( $period_id, 'wordpoints_hook_periods' );
297
+		$period = wp_cache_get($period_id, 'wordpoints_hook_periods');
298 298
 
299
-		if ( ! $period ) {
299
+		if ( ! $period) {
300 300
 
301 301
 			global $wpdb;
302 302
 
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
 				)
314 314
 			);
315 315
 
316
-			if ( ! $period ) {
316
+			if ( ! $period) {
317 317
 				return false;
318 318
 			}
319 319
 
320
-			wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
320
+			wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
321 321
 		}
322 322
 
323 323
 		return $period;
@@ -338,17 +338,17 @@  discard block
 block discarded – undo
338 338
 		WordPoints_Hook_ReactionI $reaction
339 339
 	) {
340 340
 
341
-		$signature = $this->get_period_signature( $settings, $reaction );
341
+		$signature = $this->get_period_signature($settings, $reaction);
342 342
 		$reaction_guid = $reaction->get_guid();
343 343
 
344
-		$cache_key = wp_json_encode( $reaction_guid ) . "-{$signature}-{$this->action_type}";
344
+		$cache_key = wp_json_encode($reaction_guid) . "-{$signature}-{$this->action_type}";
345 345
 
346 346
 		// Before we run the query, we try to lookup the ID in the cache.
347
-		$period_id = wp_cache_get( $cache_key, 'wordpoints_hook_period_ids_by_reaction' );
347
+		$period_id = wp_cache_get($cache_key, 'wordpoints_hook_period_ids_by_reaction');
348 348
 
349 349
 		// If we found it, we can retrieve the period by ID instead.
350
-		if ( $period_id ) {
351
-			return $this->get_period( $period_id );
350
+		if ($period_id) {
351
+			return $this->get_period($period_id);
352 352
 		}
353 353
 
354 354
 		global $wpdb;
@@ -373,18 +373,18 @@  discard block
 block discarded – undo
373 373
 				, $signature
374 374
 				, $reaction_guid['mode']
375 375
 				, $reaction_guid['store']
376
-				, wp_json_encode( $reaction_guid['context_id'] )
376
+				, wp_json_encode($reaction_guid['context_id'])
377 377
 				, $reaction_guid['id']
378 378
 				, $this->action_type
379 379
 			)
380 380
 		);
381 381
 
382
-		if ( ! $period ) {
382
+		if ( ! $period) {
383 383
 			return false;
384 384
 		}
385 385
 
386
-		wp_cache_set( $cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction' );
387
-		wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' );
386
+		wp_cache_set($cache_key, $period->id, 'wordpoints_hook_period_ids_by_reaction');
387
+		wp_cache_set($period->id, $period, 'wordpoints_hook_periods');
388 388
 
389 389
 		return $period;
390 390
 	}
@@ -392,21 +392,21 @@  discard block
 block discarded – undo
392 392
 	/**
393 393
 	 * @since 2.1.0
394 394
 	 */
395
-	public function after_hit( WordPoints_Hook_Fire $fire ) {
395
+	public function after_hit(WordPoints_Hook_Fire $fire) {
396 396
 
397
-		$periods = $this->get_settings_from_fire( $fire );
397
+		$periods = $this->get_settings_from_fire($fire);
398 398
 
399
-		if ( empty( $periods ) ) {
399
+		if (empty($periods)) {
400 400
 			return;
401 401
 		}
402 402
 
403 403
 		$this->event_args = $fire->event_args;
404 404
 		$this->action_type = $fire->action_type;
405 405
 
406
-		foreach ( $periods as $settings ) {
406
+		foreach ($periods as $settings) {
407 407
 
408 408
 			$this->add_period(
409
-				$this->get_period_signature( $settings, $fire->reaction )
409
+				$this->get_period_signature($settings, $fire->reaction)
410 410
 				, $fire
411 411
 			);
412 412
 		}
@@ -431,14 +431,14 @@  discard block
 block discarded – undo
431 431
 		WordPoints_Hook_ReactionI $reaction
432 432
 	) {
433 433
 
434
-		if ( isset( $settings['args'] ) ) {
434
+		if (isset($settings['args'])) {
435 435
 			$period_args = $settings['args'];
436 436
 		} else {
437
-			$period_args = array( $reaction->get_meta( 'target' ) );
437
+			$period_args = array($reaction->get_meta('target'));
438 438
 		}
439 439
 
440 440
 		return wordpoints_hash(
441
-			wp_json_encode( $this->get_arg_values( $period_args ) )
441
+			wp_json_encode($this->get_arg_values($period_args))
442 442
 		);
443 443
 	}
444 444
 
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	 *
453 453
 	 * @return false|object The period data, or false if not found.
454 454
 	 */
455
-	protected function add_period( $signature, WordPoints_Hook_Fire $fire ) {
455
+	protected function add_period($signature, WordPoints_Hook_Fire $fire) {
456 456
 
457 457
 		global $wpdb;
458 458
 
@@ -462,17 +462,17 @@  discard block
 block discarded – undo
462 462
 				'hit_id' => $fire->hit_id,
463 463
 				'signature' => $signature,
464 464
 			)
465
-			, array( '%d', '%s' )
465
+			, array('%d', '%s')
466 466
 		);
467 467
 
468
-		if ( ! $inserted ) {
468
+		if ( ! $inserted) {
469 469
 			return false;
470 470
 		}
471 471
 
472 472
 		$period_id = $wpdb->insert_id;
473 473
 
474 474
 		wp_cache_set(
475
-			wp_json_encode( $fire->reaction->get_guid() ) . "-{$signature}-{$this->action_type}"
475
+			wp_json_encode($fire->reaction->get_guid()) . "-{$signature}-{$this->action_type}"
476 476
 			, $period_id
477 477
 			, 'wordpoints_hook_period_ids_by_reaction'
478 478
 		);
Please login to merge, or discard this patch.
src/classes/hook/extension/hit/listeneri.php 2 patches
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.
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -18,6 +18,7 @@
 block discarded – undo
18 18
 	 * @since 2.2.0
19 19
 	 *
20 20
 	 * @param object $log The object for the points log the restriction is for.
21
+	 * @return void
21 22
 	 */
22 23
 	public function __construct( $log );
23 24
 
Please login to merge, or discard this patch.
src/classes/hook/extension/miss/listeneri.php 2 patches
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.
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -18,6 +18,7 @@
 block discarded – undo
18 18
 	 * @since 2.2.0
19 19
 	 *
20 20
 	 * @param object $log The object for the points log the restriction is for.
21
+	 * @return void
21 22
 	 */
22 23
 	public function __construct( $log );
23 24
 
Please login to merge, or discard this patch.