@@ -127,8 +127,8 @@ |
||
| 127 | 127 | public function validateRequired( $value ) |
| 128 | 128 | { |
| 129 | 129 | return is_null( $value ) |
| 130 | - || ( is_string( $value ) && trim( $value ) === '' ) |
|
| 131 | - || ( is_array( $value ) && count( $value ) < 1 ) |
|
| 130 | + || (is_string( $value ) && trim( $value ) === '') |
|
| 131 | + || (is_array( $value ) && count( $value ) < 1) |
|
| 132 | 132 | ? false |
| 133 | 133 | : true; |
| 134 | 134 | } |
@@ -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,13 +88,13 @@ 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 | - if( !method_exists( $this, $method = 'validate'.$rule )) { |
|
| 94 | + if( !method_exists( $this, $method = 'validate'.$rule ) ) { |
|
| 95 | 95 | throw new BadMethodCallException( "Method [$method] does not exist." ); |
| 96 | 96 | } |
| 97 | - if( !$this->$method( $value, $attribute, $parameters )) { |
|
| 97 | + if( !$this->$method( $value, $attribute, $parameters ) ) { |
|
| 98 | 98 | $this->addFailure( $attribute, $rule, $parameters ); |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | protected function getMessage( $attribute, $rule, array $parameters ) |
| 145 | 145 | { |
| 146 | - if( in_array( $rule, $this->sizeRules )) { |
|
| 146 | + if( in_array( $rule, $this->sizeRules ) ) { |
|
| 147 | 147 | return $this->getSizeMessage( $attribute, $rule, $parameters ); |
| 148 | 148 | } |
| 149 | 149 | $lowerRule = glsr( Helper::class )->snakeCase( $rule ); |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | protected function getRule( $attribute, $rules ) |
| 160 | 160 | { |
| 161 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
| 162 | - $rules = (array) $rules; |
|
| 161 | + if( !array_key_exists( $attribute, $this->rules ) )return; |
|
| 162 | + $rules = (array)$rules; |
|
| 163 | 163 | foreach( $this->rules[$attribute] as $rule ) { |
| 164 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
| 165 | - if( in_array( $rule, $rules )) { |
|
| 164 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
| 165 | + if( in_array( $rule, $rules ) ) { |
|
| 166 | 166 | return [$rule, $parameters]; |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | if( is_numeric( $value ) && $hasNumeric ) { |
| 181 | 181 | return $value; |
| 182 | 182 | } |
| 183 | - elseif( is_array( $value )) { |
|
| 183 | + elseif( is_array( $value ) ) { |
|
| 184 | 184 | return count( $value ); |
| 185 | 185 | } |
| 186 | 186 | return mb_strlen( $value ); |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | protected function getValue( $attribute ) |
| 209 | 209 | { |
| 210 | - if( isset( $this->data[$attribute] )) { |
|
| 210 | + if( isset($this->data[$attribute]) ) { |
|
| 211 | 211 | return $this->data[$attribute]; |
| 212 | 212 | } |
| 213 | 213 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | protected function hasRule( $attribute, $rules ) |
| 222 | 222 | { |
| 223 | - return !is_null( $this->getRule( $attribute, $rules )); |
|
| 223 | + return !is_null( $this->getRule( $attribute, $rules ) ); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | $parameters = []; |
| 260 | 260 | // example: {rule}:{parameters} |
| 261 | 261 | if( strpos( $rule, ':' ) !== false ) { |
| 262 | - list( $rule, $parameter ) = explode( ':', $rule, 2 ); |
|
| 262 | + list($rule, $parameter) = explode( ':', $rule, 2 ); |
|
| 263 | 263 | // example: {parameter1,parameter2,...} |
| 264 | 264 | $parameters = $this->parseParameters( $rule, $parameter ); |
| 265 | 265 | } |
| 266 | - $rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ))); |
|
| 266 | + $rule = ucwords( str_replace( ['-', '_'], ' ', trim( $rule ) ) ); |
|
| 267 | 267 | $rule = str_replace( ' ', '', $rule ); |
| 268 | 268 | return [$rule, $parameters]; |
| 269 | 269 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | protected function shouldStopValidating( $attribute ) |
| 291 | 291 | { |
| 292 | 292 | return $this->hasRule( $attribute, $this->implicitRules ) |
| 293 | - && isset( $this->failedRules[$attribute] ) |
|
| 293 | + && isset($this->failedRules[$attribute]) |
|
| 294 | 294 | && array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules ); |
| 295 | 295 | } |
| 296 | 296 | |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | 'regex' => __( 'The format is invalid.', 'site-reviews' ), |
| 316 | 316 | 'required' => __( 'This field is required.', 'site-reviews' ), |
| 317 | 317 | ]; |
| 318 | - $message = isset( $strings[$key] ) |
|
| 318 | + $message = isset($strings[$key]) |
|
| 319 | 319 | ? $strings[$key] |
| 320 | 320 | : false; |
| 321 | 321 | if( !$message )return; |
| 322 | - if( method_exists( $this, $method = 'replace'.$rule )) { |
|
| 322 | + if( method_exists( $this, $method = 'replace'.$rule ) ) { |
|
| 323 | 323 | $message = $this->$method( $message, $parameters ); |
| 324 | 324 | } |
| 325 | 325 | return $message; |