@@ -43,7 +43,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 ); |
@@ -64,7 +64,9 @@ discard block |
||
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 |
||
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 | } |
@@ -74,7 +74,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 ); |
@@ -73,7 +73,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -17,7 +17,7 @@ |
||
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 | } |
@@ -17,7 +17,7 @@ |
||
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 | } |
@@ -65,7 +65,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -91,7 +91,9 @@ discard block |
||
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 |
||
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'], |
@@ -14,14 +14,14 @@ |
||
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 | } |
@@ -15,11 +15,11 @@ |
||
15 | 15 | public function build( $name, array $args = [] ) |
16 | 16 | { |
17 | 17 | $roundedRating = floor( round( $args['rating'], 1 ) * 2 ) / 2; |
18 | - $percentage = glsr( Builder::class )->span([ |
|
19 | - 'style' => 'width:'.( $roundedRating / Rating::MAX_RATING * 100 ).'%;', |
|
20 | - ]); |
|
18 | + $percentage = glsr( Builder::class )->span( [ |
|
19 | + 'style' => 'width:'.($roundedRating / Rating::MAX_RATING * 100).'%;', |
|
20 | + ] ); |
|
21 | 21 | return glsr( Builder::class )->span( $percentage, [ |
22 | 22 | 'class' => 'glsr-star-rating', |
23 | - ]); |
|
23 | + ] ); |
|
24 | 24 | } |
25 | 25 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | public function build( $partialPath, array $args = [] ) |
14 | 14 | { |
15 | 15 | $className = glsr( Helper::class )->buildClassName( $partialPath, 'Modules\Html\Partials' ); |
16 | - if( !class_exists( $className )) { |
|
16 | + if( !class_exists( $className ) ) { |
|
17 | 17 | glsr_log()->error( 'Partial missing: '.$className ); |
18 | 18 | return; |
19 | 19 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function get() |
110 | 110 | { |
111 | - return empty( $this->log ) |
|
111 | + return empty($this->log) |
|
112 | 112 | ? __( 'Log is empty', 'site-reviews' ) |
113 | 113 | : $this->log; |
114 | 114 | } |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | { |
135 | 135 | $constants = (new ReflectionClass( __CLASS__ ))->getConstants(); |
136 | 136 | $constants = (array)apply_filters( Application::ID.'/log-levels', $constants ); |
137 | - if( in_array( $level, $constants, true )) { |
|
137 | + if( in_array( $level, $constants, true ) ) { |
|
138 | 138 | $entry = $this->buildLogEntry( $level, $message, $context ); |
139 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
139 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
140 | 140 | $this->reset(); |
141 | 141 | } |
142 | 142 | return $this; |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | protected function getDebugInformation() |
187 | 187 | { |
188 | 188 | $caller = debug_backtrace( false, 6 ); |
189 | - $index = array_search( 'log', array_column( $caller, 'function' )); |
|
189 | + $index = array_search( 'log', array_column( $caller, 'function' ) ); |
|
190 | 190 | if( $index === false |
191 | - || !isset( $caller[$index+2]['class'] ) |
|
192 | - || !isset( $caller[$index+2]['function'] ) |
|
191 | + || !isset($caller[$index + 2]['class']) |
|
192 | + || !isset($caller[$index + 2]['function']) |
|
193 | 193 | )return; |
194 | 194 | return sprintf( '[%s()->%s:%s] ', |
195 | - $caller[$index+2]['class'], |
|
196 | - $caller[$index+2]['function'], |
|
197 | - $caller[$index+1]['line'] |
|
195 | + $caller[$index + 2]['class'], |
|
196 | + $caller[$index + 2]['function'], |
|
197 | + $caller[$index + 1]['line'] |
|
198 | 198 | ); |
199 | 199 | } |
200 | 200 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | protected function interpolate( $message, $context = [] ) |
208 | 208 | { |
209 | - if( $this->isObjectOrArray( $message ) || !is_array( $context )) { |
|
209 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
210 | 210 | return print_r( $message, true ); |
211 | 211 | } |
212 | 212 | $replace = []; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | if( $value instanceof DateTime ) { |
235 | 235 | $value = $value->format( 'Y-m-d H:i:s' ); |
236 | 236 | } |
237 | - else if( $this->isObjectOrArray( $value )) { |
|
237 | + else if( $this->isObjectOrArray( $value ) ) { |
|
238 | 238 | $value = json_encode( $value ); |
239 | 239 | } |
240 | 240 | return (string)$value; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $this->clear(); |
251 | 251 | file_put_contents( |
252 | 252 | $this->file, |
253 | - $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' )) |
|
253 | + $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' ) ) |
|
254 | 254 | ); |
255 | 255 | } |
256 | 256 | } |
@@ -190,7 +190,9 @@ |
||
190 | 190 | if( $index === false |
191 | 191 | || !isset( $caller[$index+2]['class'] ) |
192 | 192 | || !isset( $caller[$index+2]['function'] ) |
193 | - )return; |
|
193 | + ) { |
|
194 | + return; |
|
195 | + } |
|
194 | 196 | return sprintf( '[%s()->%s:%s] ', |
195 | 197 | $caller[$index+2]['class'], |
196 | 198 | $caller[$index+2]['function'], |