@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | foreach( $this->rules as $attribute => $rules ) { |
94 | 94 | foreach( $rules as $rule ) { |
95 | 95 | $this->validateAttribute( $attribute, $rule ); |
96 | - if( $this->shouldStopValidating( $attribute ))break; |
|
96 | + if( $this->shouldStopValidating( $attribute ) )break; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | return $this->errors; |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function validateAttribute( $attribute, $rule ) |
110 | 110 | { |
111 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
111 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
112 | 112 | if( $rule == '' )return; |
113 | 113 | $value = $this->getValue( $attribute ); |
114 | - if( !method_exists( $this, $method = 'validate'.$rule )) { |
|
114 | + if( !method_exists( $this, $method = 'validate'.$rule ) ) { |
|
115 | 115 | throw new BadMethodCallException( "Method [$method] does not exist." ); |
116 | 116 | } |
117 | - if( !$this->$method( $value, $attribute, $parameters )) { |
|
117 | + if( !$this->$method( $value, $attribute, $parameters ) ) { |
|
118 | 118 | $this->addFailure( $attribute, $rule, $parameters ); |
119 | 119 | } |
120 | 120 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | protected function getMessage( $attribute, $rule, array $parameters ) |
165 | 165 | { |
166 | - if( in_array( $rule, $this->sizeRules )) { |
|
166 | + if( in_array( $rule, $this->sizeRules ) ) { |
|
167 | 167 | return $this->getSizeMessage( $attribute, $rule, $parameters ); |
168 | 168 | } |
169 | 169 | $lowerRule = glsr( Helper::class )->snakeCase( $rule ); |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | */ |
179 | 179 | protected function getRule( $attribute, $rules ) |
180 | 180 | { |
181 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
181 | + if( !array_key_exists( $attribute, $this->rules ) )return; |
|
182 | 182 | $rules = (array)$rules; |
183 | 183 | foreach( $this->rules[$attribute] as $rule ) { |
184 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
185 | - if( in_array( $rule, $rules )) { |
|
184 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
185 | + if( in_array( $rule, $rules ) ) { |
|
186 | 186 | return [$rule, $parameters]; |
187 | 187 | } |
188 | 188 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | if( is_numeric( $value ) && $hasNumeric ) { |
201 | 201 | return $value; |
202 | 202 | } |
203 | - elseif( is_array( $value )) { |
|
203 | + elseif( is_array( $value ) ) { |
|
204 | 204 | return count( $value ); |
205 | 205 | } |
206 | 206 | return mb_strlen( $value ); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function getValue( $attribute ) |
228 | 228 | { |
229 | - if( isset( $this->data[$attribute] )) { |
|
229 | + if( isset($this->data[$attribute]) ) { |
|
230 | 230 | return $this->data[$attribute]; |
231 | 231 | } |
232 | 232 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | protected function hasRule( $attribute, $rules ) |
241 | 241 | { |
242 | - return !is_null( $this->getRule( $attribute, $rules )); |
|
242 | + return !is_null( $this->getRule( $attribute, $rules ) ); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | { |
278 | 278 | $parameters = []; |
279 | 279 | if( strpos( $rule, ':' ) !== false ) { |
280 | - list( $rule, $parameter ) = explode( ':', $rule, 2 ); |
|
280 | + list($rule, $parameter) = explode( ':', $rule, 2 ); |
|
281 | 281 | $parameters = $this->parseParameters( $rule, $parameter ); |
282 | 282 | } |
283 | 283 | $rule = glsr( Helper::class )->camelCase( $rule ); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | protected function shouldStopValidating( $attribute ) |
307 | 307 | { |
308 | 308 | return $this->hasRule( $attribute, $this->implicitRules ) |
309 | - && isset( $this->failedRules[$attribute] ) |
|
309 | + && isset($this->failedRules[$attribute]) |
|
310 | 310 | && array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules ); |
311 | 311 | } |
312 | 312 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | protected function translator( $key, array $parameters ) |
320 | 320 | { |
321 | 321 | $strings = $this->strings(); |
322 | - if( isset( $strings[$key] )) { |
|
322 | + if( isset($strings[$key]) ) { |
|
323 | 323 | return $this->replace( $strings[$key], $parameters ); |
324 | 324 | } |
325 | 325 | } |
@@ -93,7 +93,9 @@ discard block |
||
93 | 93 | foreach( $this->rules as $attribute => $rules ) { |
94 | 94 | foreach( $rules as $rule ) { |
95 | 95 | $this->validateAttribute( $attribute, $rule ); |
96 | - if( $this->shouldStopValidating( $attribute ))break; |
|
96 | + if( $this->shouldStopValidating( $attribute )) { |
|
97 | + break; |
|
98 | + } |
|
97 | 99 | } |
98 | 100 | } |
99 | 101 | return $this->errors; |
@@ -109,7 +111,9 @@ discard block |
||
109 | 111 | public function validateAttribute( $attribute, $rule ) |
110 | 112 | { |
111 | 113 | list( $rule, $parameters ) = $this->parseRule( $rule ); |
112 | - if( $rule == '' )return; |
|
114 | + if( $rule == '' ) { |
|
115 | + return; |
|
116 | + } |
|
113 | 117 | $value = $this->getValue( $attribute ); |
114 | 118 | if( !method_exists( $this, $method = 'validate'.$rule )) { |
115 | 119 | throw new BadMethodCallException( "Method [$method] does not exist." ); |
@@ -178,7 +182,9 @@ discard block |
||
178 | 182 | */ |
179 | 183 | protected function getRule( $attribute, $rules ) |
180 | 184 | { |
181 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
185 | + if( !array_key_exists( $attribute, $this->rules )) { |
|
186 | + return; |
|
187 | + } |
|
182 | 188 | $rules = (array)$rules; |
183 | 189 | foreach( $this->rules[$attribute] as $rule ) { |
184 | 190 | list( $rule, $parameters ) = $this->parseRule( $rule ); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | if( strpos( $message, '%s' ) === false ) { |
29 | 29 | return $message; |
30 | 30 | } |
31 | - return preg_replace_callback( '/(%s)/', function() use( &$parameters ) { |
|
31 | + return preg_replace_callback( '/(%s)/', function() use(&$parameters) { |
|
32 | 32 | foreach( $parameters as $key => $value ) { |
33 | 33 | return array_shift( $parameters ); |
34 | 34 | } |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | public function validateRequired( $value ) |
114 | 114 | { |
115 | 115 | return is_null( $value ) |
116 | - || ( is_string( $value ) && trim( $value ) === '' ) |
|
117 | - || ( is_array( $value ) && count( $value ) < 1 ) |
|
116 | + || (is_string( $value ) && trim( $value ) === '') |
|
117 | + || (is_array( $value ) && count( $value ) < 1) |
|
118 | 118 | ? false |
119 | 119 | : true; |
120 | 120 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function enqueueAssets() |
28 | 28 | { |
29 | - if( apply_filters( 'site-reviews/assets/css', true )) { |
|
29 | + if( apply_filters( 'site-reviews/assets/css', true ) ) { |
|
30 | 30 | wp_enqueue_style( |
31 | 31 | Application::ID, |
32 | 32 | $this->getStylesheet(), |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | glsr()->version |
35 | 35 | ); |
36 | 36 | } |
37 | - if( apply_filters( 'site-reviews/assets/js', true )) { |
|
37 | + if( apply_filters( 'site-reviews/assets/js', true ) ) { |
|
38 | 38 | $dependencies = apply_filters( 'site-reviews/assets/polyfill', true ) |
39 | 39 | ? [Application::ID.'/polyfill'] |
40 | 40 | : []; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function enqueuePolyfillService() |
56 | 56 | { |
57 | - if( !apply_filters( 'site-reviews/assets/polyfill', true ))return; |
|
57 | + if( !apply_filters( 'site-reviews/assets/polyfill', true ) )return; |
|
58 | 58 | wp_enqueue_script( |
59 | 59 | Application::ID.'/polyfill', |
60 | 60 | 'https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.closest,Element.prototype.dataset,Event&flags=gated', |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | { |
71 | 71 | if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' )return; |
72 | 72 | $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
73 | - wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([ |
|
73 | + wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [ |
|
74 | 74 | 'hl' => $language, |
75 | 75 | 'onload' => 'glsr_render_recaptcha', |
76 | 76 | 'render' => 'explicit', |
77 | - ], 'https://www.google.com/recaptcha/api.js' )); |
|
78 | - $inlineScript = file_get_contents( glsr()->path( 'assets/scripts/recaptcha.js' )); |
|
77 | + ], 'https://www.google.com/recaptcha/api.js' ) ); |
|
78 | + $inlineScript = file_get_contents( glsr()->path( 'assets/scripts/recaptcha.js' ) ); |
|
79 | 79 | wp_add_inline_script( Application::ID.'/google-recaptcha', $inlineScript, 'before' ); |
80 | 80 | } |
81 | 81 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | public function inlineStyles() |
86 | 86 | { |
87 | 87 | $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
88 | - if( !apply_filters( 'site-reviews/assets/css', true ))return; |
|
89 | - if( !file_exists( $inlineStylesheetPath )) { |
|
88 | + if( !apply_filters( 'site-reviews/assets/css', true ) )return; |
|
89 | + if( !file_exists( $inlineStylesheetPath ) ) { |
|
90 | 90 | glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
91 | 91 | return; |
92 | 92 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function getFixedSelectorsForPagination() |
122 | 122 | { |
123 | - $selectors = ['#wpadminbar','.site-navigation-fixed']; |
|
123 | + $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
124 | 124 | return apply_filters( 'site-reviews/localize/pagination/selectors', $selectors ); |
125 | 125 | } |
126 | 126 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | protected function getStylesheet() |
131 | 131 | { |
132 | 132 | $currentStyle = glsr( Style::class )->style; |
133 | - return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' )) |
|
133 | + return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) ) |
|
134 | 134 | ? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' ) |
135 | 135 | : glsr()->url( 'assets/styles/'.Application::ID.'.css' ); |
136 | 136 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | 'input_error_class' => 'glsr-is-invalid', |
149 | 149 | 'input_success_class' => 'glsr-is-valid', |
150 | 150 | ]; |
151 | - $config = array_merge( $defaults, array_filter( glsr( Style::class )->validation )); |
|
151 | + $config = array_merge( $defaults, array_filter( glsr( Style::class )->validation ) ); |
|
152 | 152 | return apply_filters( 'site-reviews/localize/validation/config', $config ); |
153 | 153 | } |
154 | 154 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | $className = $this->camelCase( $name ); |
18 | 18 | $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' ); |
19 | - return !empty( $path ) |
|
19 | + return !empty($path) |
|
20 | 20 | ? __NAMESPACE__.'\\'.$path.'\\'.$className |
21 | 21 | : $className; |
22 | 22 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function buildMethodName( $name, $prefix = '' ) |
30 | 30 | { |
31 | - return lcfirst( $prefix.$this->buildClassName( $name )); |
|
31 | + return lcfirst( $prefix.$this->buildClassName( $name ) ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function buildPropertyName( $name ) |
39 | 39 | { |
40 | - return lcfirst( $this->buildClassName( $name )); |
|
40 | + return lcfirst( $this->buildClassName( $name ) ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function camelCase( $string ) |
48 | 48 | { |
49 | - $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ))); |
|
49 | + $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) ); |
|
50 | 50 | return str_replace( ' ', '', $string ); |
51 | 51 | } |
52 | 52 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function convertPathToId( $path, $prefix = '' ) |
80 | 80 | { |
81 | - return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix )); |
|
81 | + return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | $levels = explode( '.', $path ); |
91 | 91 | return array_reduce( $levels, function( $result, $value ) { |
92 | - return $result.= '['.$value.']'; |
|
92 | + return $result .= '['.$value.']'; |
|
93 | 93 | }, $prefix ); |
94 | 94 | } |
95 | 95 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function dashCase( $string ) |
101 | 101 | { |
102 | - return str_replace( '_', '-', $this->snakeCase( $string )); |
|
102 | + return str_replace( '_', '-', $this->snakeCase( $string ) ); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function filterInput( $key, array $request = [] ) |
123 | 123 | { |
124 | - if( isset( $request[$key] )) { |
|
124 | + if( isset($request[$key]) ) { |
|
125 | 125 | return $request[$key]; |
126 | 126 | } |
127 | 127 | $variable = filter_input( INPUT_POST, $key ); |
128 | - if( is_null( $variable ) && isset( $_POST[$key] )) { |
|
128 | + if( is_null( $variable ) && isset($_POST[$key]) ) { |
|
129 | 129 | $variable = $_POST[$key]; |
130 | 130 | } |
131 | 131 | return $variable; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | public function filterInputArray( $key ) |
139 | 139 | { |
140 | 140 | $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
141 | - if( empty( $variable ) && !empty( $_POST[$key] ) && is_array( $_POST[$key] )) { |
|
141 | + if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) { |
|
142 | 142 | $variable = $_POST[$key]; |
143 | 143 | } |
144 | 144 | return (array)$variable; |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | $result = []; |
155 | 155 | foreach( $array as $key => $value ) { |
156 | 156 | $newKey = ltrim( $prefix.'.'.$key, '.' ); |
157 | - if( $this->isIndexedFlatArray( $value )) { |
|
157 | + if( $this->isIndexedFlatArray( $value ) ) { |
|
158 | 158 | if( $flattenValue ) { |
159 | 159 | $value = '['.implode( ', ', $value ).']'; |
160 | 160 | } |
161 | 161 | } |
162 | - else if( is_array( $value )) { |
|
163 | - $result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey )); |
|
162 | + else if( is_array( $value ) ) { |
|
163 | + $result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ) ); |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | $result[$newKey] = $value; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | Whip::IPV4 => $cloudflareIps['v4'], |
180 | 180 | Whip::IPV6 => $cloudflareIps['v6'], |
181 | 181 | ], |
182 | - ]))->getValidIpAddress(); |
|
182 | + ] ))->getValidIpAddress(); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | { |
193 | 193 | $keys = explode( '.', $path ); |
194 | 194 | foreach( $keys as $key ) { |
195 | - if( !isset( $values[$key] )) { |
|
195 | + if( !isset($values[$key]) ) { |
|
196 | 196 | return $fallback; |
197 | 197 | } |
198 | 198 | $values = $values[$key]; |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function isIndexedArray( $array ) |
208 | 208 | { |
209 | - if( !is_array( $array )) { |
|
209 | + if( !is_array( $array ) ) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | $current = 0; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function isIndexedFlatArray( $array ) |
227 | 227 | { |
228 | - if( !is_array( $array ) || array_filter( $array, 'is_array' )) { |
|
228 | + if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) { |
|
229 | 229 | return false; |
230 | 230 | } |
231 | 231 | return $this->isIndexedArray( $array ); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function prefixString( $string, $prefix = '' ) |
240 | 240 | { |
241 | - return $prefix.str_replace( $prefix, '', trim( $string )); |
|
241 | + return $prefix.str_replace( $prefix, '', trim( $string ) ); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public function snakeCase( $string ) |
285 | 285 | { |
286 | - if( !ctype_lower( $string )) { |
|
286 | + if( !ctype_lower( $string ) ) { |
|
287 | 287 | $string = preg_replace( '/\s+/u', '', $string ); |
288 | 288 | $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string ); |
289 | 289 | $string = mb_strtolower( $string, 'UTF-8' ); |
@@ -298,6 +298,6 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public function startsWith( $needle, $haystack ) |
300 | 300 | { |
301 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
301 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
302 | 302 | } |
303 | 303 | } |