Passed
Push — master ( c5e678...d8e403 )
by Paul
06:24
created
plugin/Handlers/RegisterShortcodeButtons.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
 		foreach( $command->shortcodes as $slug => $label ) {
16 16
 			$buttonClass = glsr( Helper::class )->buildClassName( $slug.'-button', 'Shortcodes' );
17
-			if( !class_exists( $buttonClass )) {
18
-				glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ));
17
+			if( !class_exists( $buttonClass ) ) {
18
+				glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ) );
19 19
 				continue;
20 20
 			}
21 21
 			$shortcode = glsr( $buttonClass )->register( $slug, [
22 22
 				'label' => $label,
23 23
 				'title' => $label,
24
-			]);
24
+			] );
25 25
 			glsr()->mceShortcodes[$slug] = $shortcode->properties;
26 26
 		}
27 27
 	}
Please login to merge, or discard this patch.
plugin/Handlers/RegisterShortcodes.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@
 block discarded – undo
14 14
 	{
15 15
 		foreach( $command->shortcodes as $shortcode ) {
16 16
 			$shortcodeClass = glsr( Helper::class )->buildClassName( $shortcode.'-shortcode', 'Shortcodes' );
17
-			if( !class_exists( $shortcodeClass )) {
18
-				glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass ));
17
+			if( !class_exists( $shortcodeClass ) ) {
18
+				glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass ) );
19 19
 				continue;
20 20
 			}
21 21
 			add_shortcode( $shortcode, [glsr( $shortcodeClass ), 'buildShortcode'] );
Please login to merge, or discard this patch.
plugin/Handlers/RegisterWidgets.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@
 block discarded – undo
16 16
 		global $wp_widget_factory;
17 17
 		foreach( $command->widgets as $key => $values ) {
18 18
 			$widgetClass = glsr( Helper::class )->buildClassName( $key.'-widget', 'Widgets' );
19
-			if( !class_exists( $widgetClass )) {
20
-				glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass ));
19
+			if( !class_exists( $widgetClass ) ) {
20
+				glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass ) );
21 21
 				continue;
22 22
 			}
23 23
 			// Here we bypass register_widget() in order to pass our custom values to the widget
Please login to merge, or discard this patch.
plugin/Handlers/TogglePinned.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@
 block discarded – undo
12 12
 	 */
13 13
 	public function handle( Command $command )
14 14
 	{
15
-		if( !get_post( $command->id )) {
15
+		if( !get_post( $command->id ) ) {
16 16
 			return false;
17 17
 		}
18
-		if( is_null( $command->pinned )) {
18
+		if( is_null( $command->pinned ) ) {
19 19
 			$meta = get_post_meta( $command->id, 'pinned', true );
20 20
 			$command->pinned = !wp_validate_boolean( $meta );
21 21
 		}
Please login to merge, or discard this patch.
plugin/Controllers/Controller.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@
 block discarded – undo
15 15
 	 */
16 16
 	public function download( $filename, $content )
17 17
 	{
18
-		if( !current_user_can( Application::CAPABILITY ))return;
18
+		if( !current_user_can( Application::CAPABILITY )) {
19
+			return;
20
+		}
19 21
 		nocache_headers();
20 22
 		header( 'Content-Type: text/plain' );
21 23
 		header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 */
16 16
 	public function download( $filename, $content )
17 17
 	{
18
-		if( !current_user_can( Application::CAPABILITY ))return;
18
+		if( !current_user_can( Application::CAPABILITY ) )return;
19 19
 		nocache_headers();
20 20
 		header( 'Content-Type: text/plain' );
21 21
 		header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public function execute( $command )
32 32
 	{
33
-		$handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ));
34
-		if( !class_exists( $handlerClass )) {
33
+		$handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ) );
34
+		if( !class_exists( $handlerClass ) ) {
35 35
 			throw new InvalidArgumentException( 'Handler '.$handlerClass.' not found.' );
36 36
 		}
37 37
 		try {
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		catch( Exception $e ) {
41 41
 			status_header( 400 );
42
-			glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ));
42
+			glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ) );
43 43
 			glsr_log()->error( $e->getMessage() );
44 44
 		}
45 45
 	}
@@ -49,6 +49,6 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	protected function getPostId()
51 51
 	{
52
-		return intval( filter_input( INPUT_GET, 'post' ));
52
+		return intval( filter_input( INPUT_GET, 'post' ) );
53 53
 	}
54 54
 }
Please login to merge, or discard this patch.
plugin/Modules/Html.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
 	{
83 83
 		$this->render()->div( glsr( Notice::class )->get(), [
84 84
 			'id' => 'glsr-notices',
85
-		]);
85
+		] );
86 86
 	}
87 87
 
88 88
 	/**
Please login to merge, or discard this patch.
plugin/Modules/Validator/ValidationRules.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,8 +130,8 @@
 block discarded – undo
130 130
 	public function validateRequired( $attribute, $value )
131 131
 	{
132 132
 		return is_null( $value )
133
-			|| ( is_string( $value ) && trim( $value ) === '' )
134
-			|| ( is_array( $value ) && count( $value ) < 1 )
133
+			|| (is_string( $value ) && trim( $value ) === '')
134
+			|| (is_array( $value ) && count( $value ) < 1)
135 135
 			? false
136 136
 			: true;
137 137
 	}
Please login to merge, or discard this patch.
plugin/Modules/Email.php 2 patches
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.
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( ']]>', ']]&gt;', $message );
135 135
 		$message = glsr( Template::class )->build( 'partials/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.
plugin/Modules/Validator.php 2 patches
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.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		foreach( $this->rules as $attribute => $rules ) {
74 74
 			foreach( $rules as $rule ) {
75 75
 				$this->validateAttribute( $attribute, $rule );
76
-				if( $this->shouldStopValidating( $attribute ))break;
76
+				if( $this->shouldStopValidating( $attribute ) )break;
77 77
 			}
78 78
 		}
79 79
 		return $this->errors;
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function validateAttribute( $attribute, $rule )
90 90
 	{
91
-		list( $rule, $parameters ) = $this->parseRule( $rule );
91
+		list($rule, $parameters) = $this->parseRule( $rule );
92 92
 		if( $rule == '' )return;
93 93
 		$value = $this->getValue( $attribute );
94 94
 		$this->validateRequired( $attribute, $value ) || in_array( $rule, $this->implicitRules );
95
-		if( !method_exists( $this, $method = 'validate'.$rule )) {
95
+		if( !method_exists( $this, $method = 'validate'.$rule ) ) {
96 96
 			throw new BadMethodCallException( "Method [$method] does not exist." );
97 97
 		}
98
-		if( !$this->$method( $attribute, $value, $parameters )) {
98
+		if( !$this->$method( $attribute, $value, $parameters ) ) {
99 99
 			$this->addFailure( $attribute, $rule, $parameters );
100 100
 		}
101 101
 	}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	{
111 111
 		$message = $this->getMessage( $attribute, $rule, $parameters );
112 112
 		$this->errors[$attribute]['errors'][] = $message;
113
-		if( !isset( $this->errors[$attribute]['value'] )) {
113
+		if( !isset($this->errors[$attribute]['value']) ) {
114 114
 			$this->errors[$attribute]['value'] = $this->getValue( $attribute );
115 115
 		}
116 116
 	}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	protected function getMessage( $attribute, $rule, array $parameters )
149 149
 	{
150
-		if( in_array( $rule, $this->sizeRules )) {
150
+		if( in_array( $rule, $this->sizeRules ) ) {
151 151
 			return $this->getSizeMessage( $attribute, $rule, $parameters );
152 152
 		}
153 153
 		$lowerRule = glsr( Helper::class )->snakeCase( $rule );
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	protected function getRule( $attribute, $rules )
164 164
 	{
165
-		if( !array_key_exists( $attribute, $this->rules ))return;
166
-		$rules = (array) $rules;
165
+		if( !array_key_exists( $attribute, $this->rules ) )return;
166
+		$rules = (array)$rules;
167 167
 		foreach( $this->rules[$attribute] as $rule ) {
168
-			list( $rule, $parameters ) = $this->parseRule( $rule );
169
-			if( in_array( $rule, $rules )) {
168
+			list($rule, $parameters) = $this->parseRule( $rule );
169
+			if( in_array( $rule, $rules ) ) {
170 170
 				return [$rule, $parameters];
171 171
 			}
172 172
 		}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		if( is_numeric( $value ) && $hasNumeric ) {
185 185
 			return $value;
186 186
 		}
187
-		elseif( is_array( $value )) {
187
+		elseif( is_array( $value ) ) {
188 188
 			return count( $value );
189 189
 		}
190 190
 		return mb_strlen( $value );
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 */
212 212
 	protected function getValue( $attribute )
213 213
 	{
214
-		if( isset( $this->data[$attribute] )) {
214
+		if( isset($this->data[$attribute]) ) {
215 215
 			return $this->data[$attribute];
216 216
 		}
217 217
 	}
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 */
225 225
 	protected function hasRule( $attribute, $rules )
226 226
 	{
227
-		return !is_null( $this->getRule( $attribute, $rules ));
227
+		return !is_null( $this->getRule( $attribute, $rules ) );
228 228
 	}
229 229
 
230 230
 	/**
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 		$parameters = [];
265 265
 		// example: {rule}:{parameters}
266 266
 		if( strpos( $rule, ':' ) !== false ) {
267
-			list( $rule, $parameter ) = explode( ':', $rule, 2 );
267
+			list($rule, $parameter) = explode( ':', $rule, 2 );
268 268
 			// example: {parameter1,parameter2,...}
269 269
 			$parameters = $this->parseParameters( $rule, $parameter );
270 270
 		}
271
-		$rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule )));
271
+		$rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ) ) );
272 272
 		$rule = str_replace( ' ', '', $rule );
273 273
 		return [$rule, $parameters];
274 274
 	}
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	protected function shouldStopValidating( $attribute )
297 297
 	{
298 298
 		return $this->hasRule( $attribute, $this->implicitRules )
299
-			&& isset( $this->failedRules[$attribute] )
299
+			&& isset($this->failedRules[$attribute])
300 300
 			&& array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules );
301 301
 	}
302 302
 
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
 			'regex' => _x( 'The :attribute format is invalid.', ':attribute is a placeholder and should not be translated.', 'site-reviews' ),
322 322
 			'required' => _x( 'The :attribute field is required.', ':attribute is a placeholder and should not be translated.', 'site-reviews' ),
323 323
 		];
324
-		$message = isset( $strings[$key] )
324
+		$message = isset($strings[$key])
325 325
 			? $strings[$key]
326 326
 			: false;
327 327
 		if( !$message )return;
328 328
 		$message = str_replace( ':attribute', $attribute, $message );
329
-		if( method_exists( $this, $replacer = 'replace'.$rule )) {
329
+		if( method_exists( $this, $replacer = 'replace'.$rule ) ) {
330 330
 			$message = $this->$replacer( $message, $parameters );
331 331
 		}
332 332
 		return $message;
Please login to merge, or discard this patch.