Passed
Push — master ( fbb7de...43cb65 )
by Paul
25:46 queued 14:45
created
plugin/Controllers/ReviewController.php 1 patch
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 	{
27 27
 		sort( $termTaxonomyIds );
28 28
 		sort( $oldTermTaxonomyIds );
29
-		if( $termTaxonomyIds === $oldTermTaxonomyIds || !$this->isReviewPostId( $postId ))return;
29
+		if( $termTaxonomyIds === $oldTermTaxonomyIds || !$this->isReviewPostId( $postId )) {
30
+			return;
31
+		}
30 32
 		$review = glsr( ReviewManager::class )->single( get_post( $postId ));
31 33
 		$ignoredIds = array_intersect( $oldTermTaxonomyIds, $termTaxonomyIds );
32 34
 		$decreasedIds = array_diff( $oldTermTaxonomyIds, $ignoredIds );
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
 	 */
48 50
 	public function onAfterChangeStatus( $newStatus, $oldStatus, WP_Post $post )
49 51
 	{
50
-		if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return;
52
+		if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) {
53
+			return;
54
+		}
51 55
 		$review = glsr( ReviewManager::class )->single( get_post( $post->ID ));
52 56
 		if( $post->post_status == 'publish' ) {
53 57
 			glsr( CountsManager::class )->increase( $review );
@@ -63,7 +67,9 @@  discard block
 block discarded – undo
63 67
 	 */
64 68
 	public function onAfterCreate( Review $review )
65 69
 	{
66
-		if( $review->status !== 'publish' )return;
70
+		if( $review->status !== 'publish' ) {
71
+			return;
72
+		}
67 73
 		glsr( CountsManager::class )->increase( $review );
68 74
 	}
69 75
 
@@ -74,7 +80,9 @@  discard block
 block discarded – undo
74 80
 	 */
75 81
 	public function onBeforeDelete( $postId )
76 82
 	{
77
-		if( !$this->isReviewPostId( $postId ))return;
83
+		if( !$this->isReviewPostId( $postId )) {
84
+			return;
85
+		}
78 86
 		$review = glsr( ReviewManager::class )->single( get_post( $postId ));
79 87
 		glsr( CountsManager::class )->decrease( $review );
80 88
 	}
@@ -91,9 +99,13 @@  discard block
 block discarded – undo
91 99
 	{
92 100
 		if( !$this->isReviewPostId( $postId )
93 101
 			|| !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] )
94
-		)return;
102
+		) {
103
+			return;
104
+		}
95 105
 		$review = glsr( ReviewManager::class )->single( get_post( $postId ));
96
-		if( $review->$metaKey == $metaValue )return;
106
+		if( $review->$metaKey == $metaValue ) {
107
+			return;
108
+		}
97 109
 		$method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' );
98 110
 		call_user_func( [$this, $method], $review, $metaValue );
99 111
 	}
Please login to merge, or discard this patch.
plugin/Database/CountsManager.php 1 patch
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -74,7 +74,9 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function decreasePostCounts( Review $review )
76 76
 	{
77
-		if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return;
77
+		if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) {
78
+			return;
79
+		}
78 80
 		$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
79 81
 		$this->setPostCounts( $review->assigned_to, $counts );
80 82
 	}
@@ -85,7 +87,9 @@  discard block
 block discarded – undo
85 87
 	public function decreaseTermCounts( Review $review )
86 88
 	{
87 89
 		foreach( $review->term_ids as $termId ) {
88
-			if( empty( $counts = $this->getTermCounts( $termId )))continue;
90
+			if( empty( $counts = $this->getTermCounts( $termId ))) {
91
+				continue;
92
+			}
89 93
 			$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
90 94
 			$this->setTermCounts( $termId, $counts );
91 95
 		}
@@ -107,7 +111,9 @@  discard block
 block discarded – undo
107 111
 			'min' => Rating::MIN_RATING,
108 112
 		]);
109 113
 		foreach( $counts as $index => &$num ) {
110
-			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue;
114
+			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) {
115
+				continue;
116
+			}
111 117
 			$num = 0;
112 118
 		}
113 119
 		return $counts;
@@ -199,7 +205,9 @@  discard block
 block discarded – undo
199 205
 	 */
200 206
 	public function increasePostCounts( Review $review )
201 207
 	{
202
-		if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return;
208
+		if( !( get_post( $review->assigned_to ) instanceof WP_Post )) {
209
+			return;
210
+		}
203 211
 		$counts = $this->getPostCounts( $review->assigned_to );
204 212
 		$counts = empty( $counts )
205 213
 			? $this->buildPostCounts( $review->assigned_to )
@@ -249,7 +257,9 @@  discard block
 block discarded – undo
249 257
 	public function setTermCounts( $termId, array $reviewCounts )
250 258
 	{
251 259
 		$term = get_term( $termId, Application::TAXONOMY );
252
-		if( !isset( $term->term_id ))return;
260
+		if( !isset( $term->term_id )) {
261
+			return;
262
+		}
253 263
 		$ratingCounts = $this->flatten( $reviewCounts );
254 264
 		update_term_meta( $termId, static::META_COUNT, $reviewCounts );
255 265
 		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
@@ -270,7 +280,9 @@  discard block
 block discarded – undo
270 280
 			$types = array_unique( array_merge( ['local'], $types ));
271 281
 			foreach( $types as $type ) {
272 282
 				$type = $this->normalizeType( $type );
273
-				if( isset( $counts[$type] ))continue;
283
+				if( isset( $counts[$type] )) {
284
+					continue;
285
+				}
274 286
 				$counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 );
275 287
 			}
276 288
 			foreach( $reviews as $review ) {
@@ -323,7 +335,9 @@  discard block
 block discarded – undo
323 335
 		}
324 336
 		foreach( $reviewCounts as &$counts ) {
325 337
 			foreach( range( 0, Rating::MAX_RATING ) as $index ) {
326
-				if( isset( $counts[$index] ))continue;
338
+				if( isset( $counts[$index] )) {
339
+					continue;
340
+				}
327 341
 				$counts[$index] = 0;
328 342
 			}
329 343
 			ksort( $counts );
Please login to merge, or discard this patch.
plugin/Database.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 		if( empty( $assignedTo )) {
24 24
 			$assignedTo = get_post_meta( $postId, 'assigned_to', true );
25 25
 		}
26
-		if( empty( $assignedTo ))return;
26
+		if( empty( $assignedTo )) {
27
+			return;
28
+		}
27 29
 		$assignedPost = get_post( $assignedTo );
28 30
 		if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) {
29 31
 			return $assignedPost;
@@ -80,7 +82,9 @@  discard block
 block discarded – undo
80 82
 		$termIds = [];
81 83
 		foreach( $values as $value ) {
82 84
 			$term = get_term_by( $field, $value, Application::TAXONOMY );
83
-			if( !isset( $term->term_id ))continue;
85
+			if( !isset( $term->term_id )) {
86
+				continue;
87
+			}
84 88
 			$termIds[] = $term->term_id;
85 89
 		}
86 90
 		return $termIds;
@@ -127,7 +131,9 @@  discard block
 block discarded – undo
127 131
 		add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 );
128 132
 		$search = new WP_Query( $args );
129 133
 		remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 );
130
-		if( !$search->have_posts() )return;
134
+		if( !$search->have_posts() ) {
135
+			return;
136
+		}
131 137
 		$results = '';
132 138
 		while( $search->have_posts() ) {
133 139
 			$search->the_post();
Please login to merge, or discard this patch.
plugin/Shortcodes/SiteReviewsSummaryShortcode.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,8 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsSummaryShortcode extends Shortcode
8 8
 {
9
-	protected function hideOptions() {
9
+	protected function hideOptions()
10
+	{
10 11
 		return [
11 12
 			'rating' => __( 'Hide the rating', 'site-reviews' ),
12 13
 			'stars' => __( 'Hide the stars', 'site-reviews' ),
Please login to merge, or discard this patch.
plugin/Shortcodes/SiteReviewsShortcode.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,8 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsShortcode extends Shortcode
8 8
 {
9
-	protected function hideOptions() {
9
+	protected function hideOptions()
10
+	{
10 11
 		return [
11 12
 			'title' => __( 'Hide the title', 'site-reviews' ),
12 13
 			'rating' => __( 'Hide the rating', 'site-reviews' ),
Please login to merge, or discard this patch.
plugin/Shortcodes/SiteReviewsFormShortcode.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,8 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsFormShortcode extends Shortcode
8 8
 {
9
-	protected function hideOptions() {
9
+	protected function hideOptions()
10
+	{
10 11
 		return [
11 12
 			'rating' => __( 'Hide the rating field', 'site-reviews' ),
12 13
 			'title' => __( 'Hide the title field', 'site-reviews' ),
Please login to merge, or discard this patch.
plugin/Modules/Session.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -150,7 +150,9 @@  discard block
 block discarded – undo
150 150
 		if( !empty( $sessions )) {
151 151
 			$now = time();
152 152
 			foreach( $sessions as $session ) {
153
-				if( $now <= $session->expiration )continue;
153
+				if( $now <= $session->expiration ) {
154
+					continue;
155
+				}
154 156
 				$expiredSessions[] = $session->name;
155 157
 				$expiredSessions[] = str_replace( '_expires_', '_', $session->name );
156 158
 			}
@@ -193,7 +195,9 @@  discard block
 block discarded – undo
193 195
 	 */
194 196
 	protected function setCookie()
195 197
 	{
196
-		if( headers_sent() )return;
198
+		if( headers_sent() ) {
199
+			return;
200
+		}
197 201
 		$cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset;
198 202
 		$cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' )));
199 203
 		setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath );
Please login to merge, or discard this patch.
plugin/Modules/Notification.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function send( Review $review )
45 45
 	{
46
-		if( empty( $this->types ))return;
46
+		if( empty( $this->types )) {
47
+			return;
48
+		}
47 49
 		$this->review = $review;
48 50
 		$args = [
49 51
 			'link' => $this->getLink(),
@@ -146,7 +148,9 @@  discard block
 block discarded – undo
146 148
 	protected function sendToEmail( array $args )
147 149
 	{
148 150
 		$email = $this->buildEmail( $args );
149
-		if( !$this->email )return;
151
+		if( !$this->email ) {
152
+			return;
153
+		}
150 154
 		if( empty( $email->to )) {
151 155
 			glsr_log()->error( 'Email notification was not sent (missing email address)' );
152 156
 			return;
@@ -161,7 +165,9 @@  discard block
 block discarded – undo
161 165
 	 */
162 166
 	protected function sendToSlack( array $args )
163 167
 	{
164
-		if( !$this->slack )return;
168
+		if( !$this->slack ) {
169
+			return;
170
+		}
165 171
 		$notification = $this->buildSlackNotification( $args );
166 172
 		$result = $notification->send();
167 173
 		if( is_wp_error( $result )) {
Please login to merge, or discard this patch.
plugin/Modules/Validator/ValidateReview.php 1 patch
Braces   +30 added lines, -10 removed lines patch added patch discarded remove patch
@@ -175,8 +175,12 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	protected function validateAkismet()
177 177
 	{
178
-		if( !empty( $this->error ))return;
179
-		if( !glsr( Akismet::class )->isSpam( $this->request ))return;
178
+		if( !empty( $this->error )) {
179
+			return;
180
+		}
181
+		if( !glsr( Akismet::class )->isSpam( $this->request )) {
182
+			return;
183
+		}
180 184
 		$this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' );
181 185
 		$this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' );
182 186
 	}
@@ -186,8 +190,12 @@  discard block
 block discarded – undo
186 190
 	 */
187 191
 	protected function validateBlacklist()
188 192
 	{
189
-		if( !empty( $this->error ))return;
190
-		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return;
193
+		if( !empty( $this->error )) {
194
+			return;
195
+		}
196
+		if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) {
197
+			return;
198
+		}
191 199
 		$blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' );
192 200
 		if( $blacklistAction == 'reject' ) {
193 201
 			$this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' );
@@ -202,9 +210,13 @@  discard block
 block discarded – undo
202 210
 	 */
203 211
 	protected function validateCustom()
204 212
 	{
205
-		if( !empty( $this->error ))return;
213
+		if( !empty( $this->error )) {
214
+			return;
215
+		}
206 216
 		$validated = apply_filters( 'site-reviews/validate/custom', true, $this->request );
207
-		if( $validated === true )return;
217
+		if( $validated === true ) {
218
+			return;
219
+		}
208 220
 		$this->setSessionValues( 'errors', [] );
209 221
 		$this->setSessionValues( 'values', $this->request );
210 222
 		$this->error = is_string( $validated )
@@ -217,8 +229,12 @@  discard block
 block discarded – undo
217 229
 	 */
218 230
 	protected function validateHoneyPot()
219 231
 	{
220
-		if( !empty( $this->error ))return;
221
-		if( empty( $this->request['gotcha'] ))return;
232
+		if( !empty( $this->error )) {
233
+			return;
234
+		}
235
+		if( empty( $this->request['gotcha'] )) {
236
+			return;
237
+		}
222 238
 		$this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' );
223 239
 		$this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
224 240
 	}
@@ -228,9 +244,13 @@  discard block
 block discarded – undo
228 244
 	 */
229 245
 	protected function validateRecaptcha()
230 246
 	{
231
-		if( !empty( $this->error ))return;
247
+		if( !empty( $this->error )) {
248
+			return;
249
+		}
232 250
 		$status = $this->getRecaptchaStatus();
233
-		if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return;
251
+		if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] )) {
252
+			return;
253
+		}
234 254
 		if( $status == static::RECAPTCHA_EMPTY ) {
235 255
 			$this->setSessionValues( 'recaptcha', 'unset' );
236 256
 			$this->recaptchaIsUnset = true;
Please login to merge, or discard this patch.