Test Failed
Push — master ( e52611...5d5118 )
by Paul
04:30
created
plugin/Modules/Validator/ValidateReview.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		$this->validateBlacklist();
62 62
 		$this->validateAkismet();
63 63
 		$this->validateRecaptcha();
64
-		if( !empty( $this->error )) {
64
+		if( !empty($this->error) ) {
65 65
 			$this->setSessionValues( 'message', $this->error );
66 66
 		}
67 67
 		return $this;
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
 	{
85 85
 		$rules = array_intersect_key(
86 86
 			apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES ),
87
-			array_flip( $this->getOption( 'settings.submissions.required', [] ))
87
+			array_flip( $this->getOption( 'settings.submissions.required', [] ) )
88 88
 		);
89
-		$excluded = isset( $request['excluded'] )
89
+		$excluded = isset($request['excluded'])
90 90
 			? (array)json_decode( $request['excluded'] )
91 91
 			: [];
92
-		return array_diff_key( $rules, array_flip( $excluded ));
92
+		return array_diff_key( $rules, array_flip( $excluded ) );
93 93
 	}
94 94
 
95 95
 	/**
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 		if( !$integration ) {
102 102
 			return true;
103 103
 		}
104
-		if( empty( $this->request['recaptcha-token'] )) {
104
+		if( empty($this->request['recaptcha-token']) ) {
105 105
 			return null; // @see $this->validateRecaptcha()
106 106
 		}
107 107
 		if( $integration == 'custom' ) {
108 108
 			return $this->isRecaptchaValid( $this->request['recaptcha-token'] );
109 109
 		}
110 110
 		if( $integration == 'invisible-recaptcha' ) {
111
-			return boolval( apply_filters( 'google_invre_is_valid_request_filter', true ));
111
+			return boolval( apply_filters( 'google_invre_is_valid_request_filter', true ) );
112 112
 		}
113 113
 		return false;
114 114
 	}
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	protected function isRecaptchaValid( $recaptchaToken )
121 121
 	{
122
-		$endpoint = add_query_arg([
122
+		$endpoint = add_query_arg( [
123 123
 			'remoteip' => glsr( Helper::class )->getIpAddress(),
124 124
 			'response' => $recaptchaToken,
125 125
 			'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ),
126 126
 		], static::RECAPTCHA_ENDPOINT );
127
-		if( is_wp_error( $response = wp_remote_get( $endpoint ))) {
127
+		if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) {
128 128
 			glsr_log()->error( $response->get_error_message() );
129 129
 			return false;
130 130
 		}
131
-		$response = json_decode( wp_remote_retrieve_body( $response ));
132
-		if( !empty( $response->success )) {
131
+		$response = json_decode( wp_remote_retrieve_body( $response ) );
132
+		if( !empty($response->success) ) {
133 133
 			return boolval( $response->success );
134 134
 		}
135 135
 		$errorCodes = [
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	{
153 153
 		$rules = $this->getValidationRules( $request );
154 154
 		$errors = glsr( Validator::class )->validate( $request, $rules );
155
-		if( empty( $errors )) {
155
+		if( empty($errors) ) {
156 156
 			return true;
157 157
 		}
158 158
 		$this->setSessionValues( 'errors', $errors );
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	protected function setSessionValues( $type, $value, $loggedMessage = '' )
170 170
 	{
171 171
 		glsr( Session::class )->set( $this->form_id.$type, $value );
172
-		if( !empty( $loggedMessage )) {
172
+		if( !empty($loggedMessage) ) {
173 173
 			glsr_log()->warning( $loggedMessage );
174 174
 			glsr_log()->warning( $this->request );
175 175
 		}
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	protected function validateAkismet()
182 182
 	{
183
-		if( !empty( $this->error ))return;
184
-		if( !glsr( Akismet::class )->isSpam( $this->request ))return;
183
+		if( !empty($this->error) )return;
184
+		if( !glsr( Akismet::class )->isSpam( $this->request ) )return;
185 185
 		$this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' );
186 186
 		$this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' );
187 187
 	}
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	protected function validateBlacklist()
193 193
 	{
194
-		if( !empty( $this->error ))return;
195
-		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return;
194
+		if( !empty($this->error) )return;
195
+		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return;
196 196
 		$blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' );
197 197
 		if( $blacklistAction == 'reject' ) {
198 198
 			$this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' );
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	protected function validateCustom()
209 209
 	{
210
-		if( !empty( $this->error ))return;
210
+		if( !empty($this->error) )return;
211 211
 		$validated = apply_filters( 'site-reviews/validate/review/submission', true, $this->request );
212 212
 		if( $validated === true )return;
213 213
 		$this->setSessionValues( 'errors', [] );
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	protected function validateHoneyPot()
224 224
 	{
225
-		if( !empty( $this->error ))return;
226
-		if( empty( $this->request['gotcha'] ))return;
225
+		if( !empty($this->error) )return;
226
+		if( empty($this->request['gotcha']) )return;
227 227
 		$this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' );
228 228
 		$this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
229 229
 	}
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 	 */
234 234
 	protected function validateRecaptcha()
235 235
 	{
236
-		if( !empty( $this->error ))return;
236
+		if( !empty($this->error) )return;
237 237
 		$isValid = $this->isRecaptchaResponseValid();
238
-		if( is_null( $isValid )) {
238
+		if( is_null( $isValid ) ) {
239 239
 			$this->setSessionValues( 'recaptcha', true );
240 240
 			$this->recaptchaIsUnset = true;
241 241
 		}
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
 	 */
252 252
 	protected function validateRequest( array $request )
253 253
 	{
254
-		if( !$this->isRequestValid( $request )) {
254
+		if( !$this->isRequestValid( $request ) ) {
255 255
 			$this->error = __( 'Please fix the submission errors.', 'site-reviews' );
256 256
 			return $request;
257 257
 		}
258
-		if( empty( $request['title'] )) {
258
+		if( empty($request['title']) ) {
259 259
 			$request['title'] = __( 'No Title', 'site-reviews' );
260 260
 		}
261 261
 		return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request );
Please login to merge, or discard this patch.