Test Setup Failed
Push — master ( 51607c...6b8ca8 )
by Paul
03:43
created
plugin/Modules/Validator/ValidateReview.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function validateRequest( array $request )
57 57
 	{
58
-		if( !$this->isRequestValid( $request )) {
58
+		if( !$this->isRequestValid( $request ) ) {
59 59
 			$this->error = __( 'Please fix the submission errors.', 'site-reviews' );
60 60
 			return $request;
61 61
 		}
62
-		if( empty( $request['title'] )) {
62
+		if( empty($request['title']) ) {
63 63
 			$request['title'] = __( 'No Title', 'site-reviews' );
64 64
 		}
65 65
 		return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request );
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 		$rules = array_intersect_key(
74 74
 			apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES ),
75 75
 			array_flip( array_merge(
76
-				['rating','terms'],
76
+				['rating', 'terms'],
77 77
 				glsr( OptionManager::class )->get( 'settings.reviews-form.required', [] )
78
-			))
78
+			) )
79 79
 		);
80
-		$excluded = isset( $request['excluded'] )
80
+		$excluded = isset($request['excluded'])
81 81
 			? json_decode( $request['excluded'] )
82 82
 			: [];
83
-		return array_diff_key( $rules, array_flip( $excluded ));
83
+		return array_diff_key( $rules, array_flip( $excluded ) );
84 84
 	}
85 85
 
86 86
 	/**
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
 			return true;
94 94
 		}
95 95
 		$recaptchaResponse = filter_input( INPUT_POST, 'g-recaptcha-response' );
96
-		if( empty( $recaptchaResponse ))return; //if response is empty we need to return null
96
+		if( empty($recaptchaResponse) )return; //if response is empty we need to return null
97 97
 		if( $integration == 'custom' ) {
98 98
 			return $this->isRecaptchaValid( $recaptchaResponse );
99 99
 		}
100 100
 		if( $integration == 'invisible-recaptcha' ) {
101
-			return boolval( apply_filters( 'google_invre_is_valid_request_filter', true ));
101
+			return boolval( apply_filters( 'google_invre_is_valid_request_filter', true ) );
102 102
 		}
103 103
 		return false;
104 104
 	}
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	protected function isRecaptchaValid( $recaptchaResponse )
110 110
 	{
111
-		$endpoint = add_query_arg([
111
+		$endpoint = add_query_arg( [
112 112
 			'remoteip' => glsr( Helper::class )->getIpAddress(),
113 113
 			'response' => $recaptchaResponse,
114 114
 			'secret' => glsr( OptionManager::class )->get( 'settings.reviews-form.recaptcha.secret' ),
115 115
 		], 'https://www.google.com/recaptcha/api/siteverify' );
116
-		$response = json_decode( wp_remote_retrieve_body( wp_remote_get( $endpoint )));
117
-		if( !empty( $response->success )) {
116
+		$response = json_decode( wp_remote_retrieve_body( wp_remote_get( $endpoint ) ) );
117
+		if( !empty($response->success) ) {
118 118
 			return boolval( $response->success );
119 119
 		}
120 120
 		$errorCodes = [
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	{
138 138
 		$rules = $this->getValidationRules( $request );
139 139
 		$errors = glsr( Validator::class )->validate( $request, $rules );
140
-		if( empty( $errors )) {
140
+		if( empty($errors) ) {
141 141
 			return true;
142 142
 		}
143 143
 		$this->setSession( 'errors', $errors );
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	protected function setSessionValues( $type, $value, $loggedMessage = '' )
155 155
 	{
156 156
 		glsr( Session::class )->set( $this->form_id.$type, $value );
157
-		if( !empty( $loggedMessage )) {
157
+		if( !empty($loggedMessage) ) {
158 158
 			glsr_log()->warning( $loggedMessage );
159 159
 			glsr_log()->warning( $this->request );
160 160
 		}
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	protected function validateAkismet()
167 167
 	{
168
-		if( !empty( $this->error ))return;
169
-		if( !glsr( Akismet::class )->isSpam( $this->request ))return;
168
+		if( !empty($this->error) )return;
169
+		if( !glsr( Akismet::class )->isSpam( $this->request ) )return;
170 170
 		$this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' );
171 171
 		$this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' );
172 172
 	}
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	protected function validateBlacklist()
178 178
 	{
179
-		if( !empty( $this->error ))return;
180
-		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return;
179
+		if( !empty($this->error) )return;
180
+		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return;
181 181
 		$blacklistAction = glsr( OptionManager::class )->get( 'settings.reviews-form.blacklist.action' );
182 182
 		if( $blacklistAction == 'unapprove' ) {
183 183
 			$this->request['blacklisted'] = true;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	protected function validateCustom()
195 195
 	{
196
-		if( !empty( $this->error ))return;
196
+		if( !empty($this->error) )return;
197 197
 		$validated = apply_filters( 'site-reviews/validate/review/submission', true, $this->request );
198 198
 		if( $validated === true )return;
199 199
 		$this->setSessionValues( 'errors', [] );
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	protected function validateHoneyPot( array $request )
210 210
 	{
211
-		if( !empty( $this->error ))return;
212
-		if( empty( $request['gotcha'] ))return;
211
+		if( !empty($this->error) )return;
212
+		if( empty($request['gotcha']) )return;
213 213
 		$this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' );
214 214
 		$this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
215 215
 	}
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	protected function validateRecaptcha( array $request )
221 221
 	{
222
-		if( !empty( $this->error ))return;
222
+		if( !empty($this->error) )return;
223 223
 		$isValid = $this->isRecaptchaResponseValid();
224
-		if( is_null( $isValid )) {
224
+		if( is_null( $isValid ) ) {
225 225
 			$this->setSessionValues( 'recaptcha', true );
226 226
 			$this->recaptchaIsUnset = true;
227 227
 		}
Please login to merge, or discard this patch.
Braces   +31 added lines, -10 removed lines patch added patch discarded remove patch
@@ -93,7 +93,10 @@  discard block
 block discarded – undo
93 93
 			return true;
94 94
 		}
95 95
 		$recaptchaResponse = filter_input( INPUT_POST, 'g-recaptcha-response' );
96
-		if( empty( $recaptchaResponse ))return; //if response is empty we need to return null
96
+		if( empty( $recaptchaResponse )) {
97
+			return;
98
+		}
99
+		//if response is empty we need to return null
97 100
 		if( $integration == 'custom' ) {
98 101
 			return $this->isRecaptchaValid( $recaptchaResponse );
99 102
 		}
@@ -165,8 +168,12 @@  discard block
 block discarded – undo
165 168
 	 */
166 169
 	protected function validateAkismet()
167 170
 	{
168
-		if( !empty( $this->error ))return;
169
-		if( !glsr( Akismet::class )->isSpam( $this->request ))return;
171
+		if( !empty( $this->error )) {
172
+			return;
173
+		}
174
+		if( !glsr( Akismet::class )->isSpam( $this->request )) {
175
+			return;
176
+		}
170 177
 		$this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' );
171 178
 		$this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' );
172 179
 	}
@@ -176,8 +183,12 @@  discard block
 block discarded – undo
176 183
 	 */
177 184
 	protected function validateBlacklist()
178 185
 	{
179
-		if( !empty( $this->error ))return;
180
-		if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return;
186
+		if( !empty( $this->error )) {
187
+			return;
188
+		}
189
+		if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) {
190
+			return;
191
+		}
181 192
 		$blacklistAction = glsr( OptionManager::class )->get( 'settings.reviews-form.blacklist.action' );
182 193
 		if( $blacklistAction == 'unapprove' ) {
183 194
 			$this->request['blacklisted'] = true;
@@ -193,9 +204,13 @@  discard block
 block discarded – undo
193 204
 	 */
194 205
 	protected function validateCustom()
195 206
 	{
196
-		if( !empty( $this->error ))return;
207
+		if( !empty( $this->error )) {
208
+			return;
209
+		}
197 210
 		$validated = apply_filters( 'site-reviews/validate/review/submission', true, $this->request );
198
-		if( $validated === true )return;
211
+		if( $validated === true ) {
212
+			return;
213
+		}
199 214
 		$this->setSessionValues( 'errors', [] );
200 215
 		$this->setSessionValues( 'values', $this->request );
201 216
 		$this->error = is_string( $validated )
@@ -208,8 +223,12 @@  discard block
 block discarded – undo
208 223
 	 */
209 224
 	protected function validateHoneyPot( array $request )
210 225
 	{
211
-		if( !empty( $this->error ))return;
212
-		if( empty( $request['gotcha'] ))return;
226
+		if( !empty( $this->error )) {
227
+			return;
228
+		}
229
+		if( empty( $request['gotcha'] )) {
230
+			return;
231
+		}
213 232
 		$this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' );
214 233
 		$this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' );
215 234
 	}
@@ -219,7 +238,9 @@  discard block
 block discarded – undo
219 238
 	 */
220 239
 	protected function validateRecaptcha( array $request )
221 240
 	{
222
-		if( !empty( $this->error ))return;
241
+		if( !empty( $this->error )) {
242
+			return;
243
+		}
223 244
 		$isValid = $this->isRecaptchaResponseValid();
224 245
 		if( is_null( $isValid )) {
225 246
 			$this->setSessionValues( 'recaptcha', true );
Please login to merge, or discard this patch.
plugin/Modules/Email.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		$this->message = $this->buildHtmlMessage( $email );
44 44
 		$this->subject = $email['subject'];
45 45
 		$this->to = $email['to'];
46
-		add_action( 'phpmailer_init', [ $this, 'buildPlainTextMessage'] );
46
+		add_action( 'phpmailer_init', [$this, 'buildPlainTextMessage'] );
47 47
 		return $this;
48 48
 	}
49 49
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public function buildPlainTextMessage( $phpmailer )
85 85
 	{
86
-		if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return;
86
+		if( $phpmailer->ContentType === 'text/plain' || !empty($phpmailer->AltBody) )return;
87 87
 		$message = $this->stripHtmlTags( $phpmailer->Body );
88 88
 		$phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this );
89 89
 	}
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 			'from',
100 100
 			'reply-to',
101 101
 		];
102
-		$headers = array_intersect_key( $email, array_flip( $allowed ));
102
+		$headers = array_intersect_key( $email, array_flip( $allowed ) );
103 103
 		$headers = array_filter( $headers );
104 104
 		foreach( $headers as $key => $value ) {
105
-			unset( $headers[ $key ] );
105
+			unset($headers[$key]);
106 106
 			$headers[] = "{$key}: {$value}";
107 107
 		}
108 108
 		$headers[] = 'Content-Type: text/html';
@@ -114,16 +114,16 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	protected function buildHtmlMessage( $email )
116 116
 	{
117
-		$template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ));
118
-		if( !empty( $template )) {
117
+		$template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) );
118
+		if( !empty($template) ) {
119 119
 			$message = glsr( Template::class )->interpolate( $template, $email['template-tags'] );
120 120
 		}
121 121
 		else if( $email['template'] ) {
122 122
 			$message = glsr( Template::class )->build( 'templates/'.$email['template'], [
123 123
 				'context' => $email['template-tags'],
124
-			]);
124
+			] );
125 125
 		}
126
-		if( !isset( $message )) {
126
+		if( !isset($message) ) {
127 127
 			$message = $email['message'];
128 128
 		}
129 129
 		$message = $email['before'].$message.$email['after'];
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		$message = str_replace( ']]>', ']]>', $message );
135 135
 		$message = glsr( Template::class )->build( 'email/index', [
136 136
 			'context' => ['message' => $message],
137
-		]);
137
+		] );
138 138
 		return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this );
139 139
 	}
140 140
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			'to' => '',
161 161
 		];
162 162
 		$email = shortcode_atts( $defaults, $email );
163
-		if( empty( $email['reply-to'] )) {
163
+		if( empty($email['reply-to']) ) {
164 164
 			$email['reply-to'] = $email['from'];
165 165
 		}
166 166
 		return apply_filters( 'site-reviews/email/compose', $email, $this );
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,9 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function send()
66 66
 	{
67
-		if( !$this->message || !$this->subject || !$this->to )return;
67
+		if( !$this->message || !$this->subject || !$this->to ) {
68
+			return;
69
+		}
68 70
 		$sent = wp_mail(
69 71
 			$this->to,
70 72
 			$this->subject,
@@ -83,7 +85,9 @@  discard block
 block discarded – undo
83 85
 	 */
84 86
 	public function buildPlainTextMessage( $phpmailer )
85 87
 	{
86
-		if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return;
88
+		if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody )) {
89
+			return;
90
+		}
87 91
 		$message = $this->stripHtmlTags( $phpmailer->Body );
88 92
 		$phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this );
89 93
 	}
Please login to merge, or discard this patch.
plugin/Modules/Validator.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		foreach( $this->rules as $attribute => $rules ) {
75 75
 			foreach( $rules as $rule ) {
76 76
 				$this->validateAttribute( $attribute, $rule );
77
-				if( $this->shouldStopValidating( $attribute ))break;
77
+				if( $this->shouldStopValidating( $attribute ) )break;
78 78
 			}
79 79
 		}
80 80
 		return $this->errors;
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function validateAttribute( $attribute, $rule )
91 91
 	{
92
-		list( $rule, $parameters ) = $this->parseRule( $rule );
92
+		list($rule, $parameters) = $this->parseRule( $rule );
93 93
 		if( $rule == '' )return;
94 94
 		$value = $this->getValue( $attribute );
95 95
 		$this->validateRequired( $attribute, $value ) || in_array( $rule, $this->implicitRules );
96
-		if( !method_exists( $this, $method = 'validate'.$rule )) {
96
+		if( !method_exists( $this, $method = 'validate'.$rule ) ) {
97 97
 			throw new BadMethodCallException( "Method [$method] does not exist." );
98 98
 		}
99
-		if( !$this->$method( $attribute, $value, $parameters )) {
99
+		if( !$this->$method( $attribute, $value, $parameters ) ) {
100 100
 			$this->addFailure( $attribute, $rule, $parameters );
101 101
 		}
102 102
 	}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	{
112 112
 		$message = $this->getMessage( $attribute, $rule, $parameters );
113 113
 		$this->errors[$attribute]['errors'][] = $message;
114
-		if( !isset( $this->errors[$attribute]['value'] )) {
114
+		if( !isset($this->errors[$attribute]['value']) ) {
115 115
 			$this->errors[$attribute]['value'] = $this->getValue( $attribute );
116 116
 		}
117 117
 	}
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	protected function getMessage( $attribute, $rule, array $parameters )
150 150
 	{
151
-		if( in_array( $rule, $this->sizeRules )) {
151
+		if( in_array( $rule, $this->sizeRules ) ) {
152 152
 			return $this->getSizeMessage( $attribute, $rule, $parameters );
153 153
 		}
154 154
 		$lowerRule = glsr( Helper::class )->snakeCase( $rule );
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	protected function getRule( $attribute, $rules )
165 165
 	{
166
-		if( !array_key_exists( $attribute, $this->rules ))return;
167
-		$rules = (array) $rules;
166
+		if( !array_key_exists( $attribute, $this->rules ) )return;
167
+		$rules = (array)$rules;
168 168
 		foreach( $this->rules[$attribute] as $rule ) {
169
-			list( $rule, $parameters ) = $this->parseRule( $rule );
170
-			if( in_array( $rule, $rules )) {
169
+			list($rule, $parameters) = $this->parseRule( $rule );
170
+			if( in_array( $rule, $rules ) ) {
171 171
 				return [$rule, $parameters];
172 172
 			}
173 173
 		}
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		if( is_numeric( $value ) && $hasNumeric ) {
186 186
 			return $value;
187 187
 		}
188
-		elseif( is_array( $value )) {
188
+		elseif( is_array( $value ) ) {
189 189
 			return count( $value );
190 190
 		}
191 191
 		return mb_strlen( $value );
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	protected function getValue( $attribute )
214 214
 	{
215
-		if( isset( $this->data[$attribute] )) {
215
+		if( isset($this->data[$attribute]) ) {
216 216
 			return $this->data[$attribute];
217 217
 		}
218 218
 	}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	protected function hasRule( $attribute, $rules )
227 227
 	{
228
-		return !is_null( $this->getRule( $attribute, $rules ));
228
+		return !is_null( $this->getRule( $attribute, $rules ) );
229 229
 	}
230 230
 
231 231
 	/**
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
 		$parameters = [];
266 266
 		// example: {rule}:{parameters}
267 267
 		if( strpos( $rule, ':' ) !== false ) {
268
-			list( $rule, $parameter ) = explode( ':', $rule, 2 );
268
+			list($rule, $parameter) = explode( ':', $rule, 2 );
269 269
 			// example: {parameter1,parameter2,...}
270 270
 			$parameters = $this->parseParameters( $rule, $parameter );
271 271
 		}
272
-		$rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule )));
272
+		$rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ) ) );
273 273
 		$rule = str_replace( ' ', '', $rule );
274 274
 		return [$rule, $parameters];
275 275
 	}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	protected function shouldStopValidating( $attribute )
298 298
 	{
299 299
 		return $this->hasRule( $attribute, $this->implicitRules )
300
-			&& isset( $this->failedRules[$attribute] )
300
+			&& isset($this->failedRules[$attribute])
301 301
 			&& array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules );
302 302
 	}
303 303
 
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
 	protected function translator( $key, $rule, $attribute, array $parameters )
312 312
 	{
313 313
 		$strings = glsr( Strings::class )->validation();
314
-		$message = isset( $strings[$key] )
314
+		$message = isset($strings[$key])
315 315
 			? $strings[$key]
316 316
 			: false;
317 317
 		if( !$message )return;
318 318
 		$message = str_replace( ':attribute', $attribute, $message );
319
-		if( method_exists( $this, $replacer = 'replace'.$rule )) {
319
+		if( method_exists( $this, $replacer = 'replace'.$rule ) ) {
320 320
 			$message = $this->$replacer( $message, $parameters );
321 321
 		}
322 322
 		return $message;
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,7 +74,9 @@  discard block
 block discarded – undo
74 74
 		foreach( $this->rules as $attribute => $rules ) {
75 75
 			foreach( $rules as $rule ) {
76 76
 				$this->validateAttribute( $attribute, $rule );
77
-				if( $this->shouldStopValidating( $attribute ))break;
77
+				if( $this->shouldStopValidating( $attribute )) {
78
+					break;
79
+				}
78 80
 			}
79 81
 		}
80 82
 		return $this->errors;
@@ -90,7 +92,9 @@  discard block
 block discarded – undo
90 92
 	public function validateAttribute( $attribute, $rule )
91 93
 	{
92 94
 		list( $rule, $parameters ) = $this->parseRule( $rule );
93
-		if( $rule == '' )return;
95
+		if( $rule == '' ) {
96
+			return;
97
+		}
94 98
 		$value = $this->getValue( $attribute );
95 99
 		$this->validateRequired( $attribute, $value ) || in_array( $rule, $this->implicitRules );
96 100
 		if( !method_exists( $this, $method = 'validate'.$rule )) {
@@ -163,7 +167,9 @@  discard block
 block discarded – undo
163 167
 	 */
164 168
 	protected function getRule( $attribute, $rules )
165 169
 	{
166
-		if( !array_key_exists( $attribute, $this->rules ))return;
170
+		if( !array_key_exists( $attribute, $this->rules )) {
171
+			return;
172
+		}
167 173
 		$rules = (array) $rules;
168 174
 		foreach( $this->rules[$attribute] as $rule ) {
169 175
 			list( $rule, $parameters ) = $this->parseRule( $rule );
@@ -314,7 +320,9 @@  discard block
 block discarded – undo
314 320
 		$message = isset( $strings[$key] )
315 321
 			? $strings[$key]
316 322
 			: false;
317
-		if( !$message )return;
323
+		if( !$message ) {
324
+			return;
325
+		}
318 326
 		$message = str_replace( ':attribute', $attribute, $message );
319 327
 		if( method_exists( $this, $replacer = 'replace'.$rule )) {
320 328
 			$message = $this->$replacer( $message, $parameters );
Please login to merge, or discard this patch.
plugin/Modules/Translator.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		$translations = $this->getSettings();
32 32
 		$entries = $this->filter( $translations, $this->entries() )->results();
33
-		array_walk( $translations, function( &$entry ) use( $entries ) {
33
+		array_walk( $translations, function( &$entry ) use($entries) {
34 34
 			$entry['desc'] = array_key_exists( $entry['id'], $entries )
35 35
 				? $this->getEntryString( $entries[$entry['id']], 'msgctxt' )
36 36
 				: '';
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function entries()
45 45
 	{
46
-		if( !is_array( $this->entries )) {
46
+		if( !is_array( $this->entries ) ) {
47 47
 			try {
48 48
 				$entries = $this->normalize(
49
-					Parser::parseFile( glsr()->path( 'languages/site-reviews.pot' ))->getEntries()
49
+					Parser::parseFile( glsr()->path( 'languages/site-reviews.pot' ) )->getEntries()
50 50
 				);
51 51
 			}
52 52
 			catch( Exception $e ) {
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	public function filter( $filterWith = null, $entries = null, $intersect = true )
79 79
 	{
80
-		if( !is_array( $entries )) {
80
+		if( !is_array( $entries ) ) {
81 81
 			$entries = $this->results;
82 82
 		}
83
-		if( !is_array( $filterWith )) {
83
+		if( !is_array( $filterWith ) ) {
84 84
 			$filterWith = $this->getSettings();
85 85
 		}
86
-		$keys = array_flip( array_column( $filterWith, 'id' ));
86
+		$keys = array_flip( array_column( $filterWith, 'id' ) );
87 87
 		$this->results = $intersect
88 88
 			? array_intersect_key( $entries, $keys )
89 89
 			: array_diff_key( $entries, $keys );
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	{
101 101
 		return $this->translate( $translation, $domain, [
102 102
 			'single' => $text,
103
-		]);
103
+		] );
104 104
 	}
105 105
 
106 106
 	/**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		return $this->translate( $translation, $domain, [
116 116
 			'context' => $context,
117 117
 			'single' => $text,
118
-		]);
118
+		] );
119 119
 	}
120 120
 
121 121
 	/**
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 			'number' => $number,
133 133
 			'plural' => $plural,
134 134
 			'single' => $single,
135
-		]);
135
+		] );
136 136
 	}
137 137
 
138 138
 	/**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 			'number' => $number,
152 152
 			'plural' => $plural,
153 153
 			'single' => $single,
154
-		]);
154
+		] );
155 155
 	}
156 156
 
157 157
 	/**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	public function render( $template, array $entry )
162 162
 	{
163 163
 		$data = array_combine(
164
-			array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry )),
164
+			array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ),
165 165
 			$entry
166 166
 		);
167 167
 		ob_start();
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
 				'p1' => $this->getEntryString( $entry, 'msgid_plural' ),
199 199
 				's1' => $this->getEntryString( $entry, 'msgid' ),
200 200
 			];
201
-			$text = !empty( $data['p1'] )
201
+			$text = !empty($data['p1'])
202 202
 				? sprintf( '%s | %s', $data['s1'], $data['p1'] )
203 203
 				: $data['s1'];
204 204
 			$rendered .= $this->render( 'result', [
205 205
 				'entry' => wp_json_encode( $data ),
206 206
 				'text' => wp_strip_all_tags( $text ),
207
-			]);
207
+			] );
208 208
 		}
209 209
 		if( $resetAfterRender ) {
210 210
 			$this->reset();
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 	public function search( $needle = '' )
238 238
 	{
239 239
 		$this->reset();
240
-		$needle = trim( strtolower( $needle ));
240
+		$needle = trim( strtolower( $needle ) );
241 241
 		foreach( $this->entries() as $key => $entry ) {
242
-			$single = strtolower( $this->getEntryString( $entry, 'msgid' ));
243
-			$plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ));
242
+			$single = strtolower( $this->getEntryString( $entry, 'msgid' ) );
243
+			$plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) );
244 244
 			if( strlen( $needle ) < static::SEARCH_THRESHOLD ) {
245
-				if( in_array( $needle, [$single, $plural] )) {
245
+				if( in_array( $needle, [$single, $plural] ) ) {
246 246
 					$this->results[$key] = $entry;
247 247
 				}
248 248
 			}
@@ -266,19 +266,19 @@  discard block
 block discarded – undo
266 266
 		$args = $this->normalizeTranslationArgs( $args );
267 267
 		extract( $args );
268 268
 		$strings = $this->getSettings();
269
-		$strings = array_filter( $strings, function( $string ) use( $single, $plural ) {
269
+		$strings = array_filter( $strings, function( $string ) use($single, $plural) {
270 270
 			return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' )
271 271
 				&& $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' );
272 272
 		});
273
-		if( empty( $strings )) {
273
+		if( empty($strings) ) {
274 274
 			return $original;
275 275
 		}
276 276
 		$string = current( $strings );
277 277
 		$translations = get_translations_for_domain( $domain );
278
-		if( !empty( $string['s2'] )) {
278
+		if( !empty($string['s2']) ) {
279 279
 			$single = $string['s2'];
280 280
 		}
281
-		if( !empty( $string['p2'] )) {
281
+		if( !empty($string['p2']) ) {
282 282
 			$plural = $string['p2'];
283 283
 		}
284 284
 		return $string['type'] == 'plural'
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	protected function getEntryString( array $entry, $key )
294 294
 	{
295
-		return isset( $entry[$key] )
296
-			? implode( '', (array) $entry[$key] )
295
+		return isset($entry[$key])
296
+			? implode( '', (array)$entry[$key] )
297 297
 			: '';
298 298
 	}
299 299
 
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	protected function getSettings()
304 304
 	{
305 305
 		$settings = glsr( OptionManager::class )->get( 'settings' );
306
-		return isset( $settings['strings'] )
307
-			? $this->normalizeSettings( (array) $settings['strings'] )
306
+		return isset($settings['strings'])
307
+			? $this->normalizeSettings( (array)$settings['strings'] )
308 308
 			: [];
309 309
 	}
310 310
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 		$keys = [
317 317
 			'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]',
318 318
 		];
319
-		array_walk( $entries, function( &$entry ) use( $keys ) {
319
+		array_walk( $entries, function( &$entry ) use($keys) {
320 320
 			foreach( $keys as $key ) {
321 321
 				$entry = $this->normalizeEntryString( $entry, $key );
322 322
 			}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 */
331 331
 	protected function normalizeEntryString( array $entry, $key )
332 332
 	{
333
-		if( isset( $entry[$key] )) {
333
+		if( isset($entry[$key]) ) {
334 334
 			$entry[$key] = $this->getEntryString( $entry, $key );
335 335
 		}
336 336
 		return $entry;
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 		$defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' );
345 345
 		$strings = array_filter( $strings, 'is_array' );
346 346
 		foreach( $strings as &$string ) {
347
-			$string['type'] = isset( $string['p1'] ) ? 'plural' : 'single';
347
+			$string['type'] = isset($string['p1']) ? 'plural' : 'single';
348 348
 			$string = wp_parse_args( $string, $defaultString );
349 349
 		}
350 350
 		return array_filter( $strings, function( $string ) {
351
-			return !empty( $string['id'] );
351
+			return !empty($string['id']);
352 352
 		});
353 353
 	}
354 354
 
Please login to merge, or discard this patch.
plugin/Modules/Upgrade.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		natsort( $routines );
17 17
 		array_walk( $routines, function( $routine ) {
18 18
 			$version = str_replace( strtolower( __CLASS__ ).'_', '', $routine );
19
-			if( version_compare( glsr()->version, $version, '>=' ))return;
19
+			if( version_compare( glsr()->version, $version, '>=' ) )return;
20 20
 			call_user_func( [$this, $routine] );
21 21
 		});
22 22
 		$this->updateVersion();
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	public function updateVersion()
29 29
 	{
30 30
 		$currentVersion = glsr( OptionManager::class )->get( 'version' );
31
-		if( version_compare( $currentVersion, glsr()->version, '<' )) {
31
+		if( version_compare( $currentVersion, glsr()->version, '<' ) ) {
32 32
 			glsr( OptionManager::class )->set( 'version', glsr()->version );
33 33
 		}
34 34
 		if( $currentVersion != glsr()->version ) {
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 		natsort( $routines );
17 17
 		array_walk( $routines, function( $routine ) {
18 18
 			$version = str_replace( strtolower( __CLASS__ ).'_', '', $routine );
19
-			if( version_compare( glsr()->version, $version, '>=' ))return;
19
+			if( version_compare( glsr()->version, $version, '>=' )) {
20
+				return;
21
+			}
20 22
 			call_user_func( [$this, $routine] );
21 23
 		});
22 24
 		$this->updateVersion();
@@ -37,5 +39,6 @@  discard block
 block discarded – undo
37 39
 	}
38 40
 
39 41
 	protected function upgrade_3_0_0()
40
-	{}
42
+	{
43
+}
41 44
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/Fields/Honeypot.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 			'style' => 'display:none!important',
18 18
 			'tabindex' => '-1',
19 19
 			'type' => 'text',
20
-		]);
20
+		] );
21 21
 		$this->builder->tag = 'input';
22 22
 		return $this->builder->getOpeningTag();
23 23
 	}
Please login to merge, or discard this patch.
plugin/Modules/Html/Fields/YesNo.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 				'no' => __( 'No', 'site-reviews' ),
18 18
 				'yes' => __( 'Yes', 'site-reviews' ),
19 19
 			],
20
-		]);
20
+		] );
21 21
 		$this->builder->tag = 'input';
22 22
 		return $this->builder->buildFormInput();
23 23
 	}
Please login to merge, or discard this patch.
plugin/Modules/Html/Builder.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	{
66 66
 		$instance = new static();
67 67
 		$instance->setTagFromMethod( $method );
68
-		call_user_func_array( [$instance, 'normalize'], $args += ['',''] );
68
+		call_user_func_array( [$instance, 'normalize'], $args += ['', ''] );
69 69
 		$tags = array_merge( static::TAGS_FORM, static::TAGS_STRUCTURE, static::TAGS_TEXT );
70 70
 		$generatedTag = in_array( $instance->tag, $tags )
71 71
 			? $instance->buildTag()
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 			'render' => 'is_bool',
90 90
 			'tag' => 'is_string',
91 91
 		];
92
-		if( !isset( $properties[$property] )
93
-			|| empty( array_filter( [$value], $properties[$property] ))
92
+		if( !isset($properties[$property])
93
+			|| empty(array_filter( [$value], $properties[$property] ))
94 94
 		)return;
95 95
 		$this->$property = $value;
96 96
 	}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function getOpeningTag()
110 110
 	{
111
-		$attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString();
111
+		$attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString();
112 112
 		return '<'.trim( $this->tag.' '.$attributes ).'>';
113 113
 	}
114 114
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	protected function buildCustomField()
119 119
 	{
120 120
 		$className = glsr( Helper::class )->buildClassName( $this->tag, __NAMESPACE__.'\Fields' );
121
-		if( !class_exists( $className )) {
121
+		if( !class_exists( $className ) ) {
122 122
 			glsr_log()->error( 'Field missing: '.$className );
123 123
 			return;
124 124
 		}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	protected function buildDefaultTag( $text = '' )
132 132
 	{
133
-		if( empty( $text )) {
133
+		if( empty($text) ) {
134 134
 			$text = $this->args['text'];
135 135
 		}
136 136
 		return $this->getOpeningTag().$text.$this->getClosingTag();
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	protected function buildFieldDescription()
143 143
 	{
144
-		if( !empty( $this->args['description'] )) {
144
+		if( !empty($this->args['description']) ) {
145 145
 			return $this->small( $this->args['description'] );
146 146
 		}
147 147
 	}
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	protected function buildFormInput()
153 153
 	{
154
-		if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) {
154
+		if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) {
155 155
 			return $this->buildFormLabel().$this->getOpeningTag();
156 156
 		}
157
-		return empty( $this->args['options'] )
157
+		return empty($this->args['options'])
158 158
 			? $this->buildFormInputChoice()
159 159
 			: $this->buildFormInputMultiChoice();
160 160
 	}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 				'name' => $this->args['name'].'[]',
179 179
 				'text' => $this->args['options'][$key],
180 180
 				'value' => $key,
181
-			]));
181
+			]) );
182 182
 		});
183 183
 		return $this->ul( $options );
184 184
 	}
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	protected function buildFormLabel()
190 190
 	{
191
-		if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return;
192
-		return $this->label([
191
+		if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return;
192
+		return $this->label( [
193 193
 			'for' => $this->args['id'],
194 194
 			'text' => $this->args['label'],
195
-		]);
195
+		] );
196 196
 	}
197 197
 
198 198
 	/**
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
 	protected function buildFormSelectOptions()
210 210
 	{
211 211
 		return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) {
212
-			return $carry.$this->option([
212
+			return $carry.$this->option( [
213 213
 				'selected' => $this->args['value'] == $key,
214 214
 				'text' => $this->args['options'][$key],
215 215
 				'value' => $key,
216
-			]);
216
+			] );
217 217
 		});
218 218
 	}
219 219
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 */
231 231
 	protected function buildTag()
232 232
 	{
233
-		if( !in_array( $this->tag, static::TAGS_FORM )) {
233
+		if( !in_array( $this->tag, static::TAGS_FORM ) ) {
234 234
 			return $this->buildDefaultTag();
235 235
 		}
236 236
 		return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription();
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	protected function normalize( ...$params )
244 244
 	{
245
-		if( is_string( $params[0] ) || is_numeric( $params[0] )) {
245
+		if( is_string( $params[0] ) || is_numeric( $params[0] ) ) {
246 246
 			$this->setNameOrTextAttributeForTag( $params[0] );
247 247
 		}
248
-		if( is_array( $params[0] )) {
248
+		if( is_array( $params[0] ) ) {
249 249
 			$this->args += $params[0];
250 250
 		}
251
-		else if( is_array( $params[1] )) {
251
+		else if( is_array( $params[1] ) ) {
252 252
 			$this->args += $params[1];
253 253
 		}
254 254
 		$this->args = glsr( BuilderDefaults::class )->merge( $this->args );
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	protected function setTagFromMethod( $method )
274 274
 	{
275 275
 		$this->tag = strtolower( $method );
276
-		if( in_array( $this->tag, static::INPUT_TYPES )) {
276
+		if( in_array( $this->tag, static::INPUT_TYPES ) ) {
277 277
 			$this->args['type'] = $this->tag;
278 278
 			$this->tag = 'input';
279 279
 		}
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,9 @@  discard block
 block discarded – undo
91 91
 		];
92 92
 		if( !isset( $properties[$property] )
93 93
 			|| empty( array_filter( [$value], $properties[$property] ))
94
-		)return;
94
+		) {
95
+			return;
96
+		}
95 97
 		$this->$property = $value;
96 98
 	}
97 99
 
@@ -188,7 +190,9 @@  discard block
 block discarded – undo
188 190
 	 */
189 191
 	protected function buildFormLabel()
190 192
 	{
191
-		if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return;
193
+		if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' ) {
194
+			return;
195
+		}
192 196
 		return $this->label([
193 197
 			'for' => $this->args['id'],
194 198
 			'text' => $this->args['label'],
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviewsForm.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
 	{
15 15
 		$partial = glsr( Html::class )->buildTemplate( 'templates/reviews-form', [
16 16
 			'globals' => $args,
17
-		]);
17
+		] );
18 18
 		$form = glsr( Builder::class )->form( $partial, [
19 19
 			'class' => 'glsr-form',
20 20
 			'id' => $args['id'],
21 21
 			'method' => 'post',
22
-		]);
22
+		] );
23 23
 		return glsr( Builder::class )->div( $form, [
24 24
 			'class' => 'glsr-form-wrap '.$args['class'],
25
-		]);
25
+		] );
26 26
 	}
27 27
 }
Please login to merge, or discard this patch.