@@ -82,8 +82,8 @@ |
||
| 82 | 82 | */ |
| 83 | 83 | private function loadValidations() |
| 84 | 84 | { |
| 85 | - foreach (config('laravel-validate.rules', []) as $rule) { |
|
| 86 | - Validator::extend('validate-'.$rule['name'], function ($attribute, $value, $parameters, $validator) use ($rule) { |
|
| 85 | + foreach (config('laravel-validate.rules', [ ]) as $rule) { |
|
| 86 | + Validator::extend('validate-'.$rule[ 'name' ], function($attribute, $value, $parameters, $validator) use ($rule) { |
|
| 87 | 87 | $rule = new $rule(...$parameters); |
| 88 | 88 | |
| 89 | 89 | return $rule->passes($attribute, $value); |
@@ -9,20 +9,20 @@ discard block |
||
| 9 | 9 | * |
| 10 | 10 | * @return void |
| 11 | 11 | */ |
| 12 | - private function setCountries(array|null $countries) |
|
| 12 | + private function setCountries(array | null $countries) |
|
| 13 | 13 | { |
| 14 | 14 | if (empty($countries)) { |
| 15 | - $this->countries = []; |
|
| 15 | + $this->countries = [ ]; |
|
| 16 | 16 | |
| 17 | 17 | return; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - if (is_array($countries[0])) { |
|
| 21 | - $countries = $countries[0]; |
|
| 20 | + if (is_array($countries[ 0 ])) { |
|
| 21 | + $countries = $countries[ 0 ]; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | foreach ($countries as $country) { |
| 25 | - $this->countries[] = $country; |
|
| 25 | + $this->countries[ ] = $country; |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | private function isIbanValid(string $iban) |
| 35 | 35 | { |
| 36 | - if (! $this->checkIbanFormat($iban)) { |
|
| 36 | + if ( ! $this->checkIbanFormat($iban)) { |
|
| 37 | 37 | return false; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | private function isCountryValid(string $country, string $ibanCountryCode) |
| 128 | 128 | { |
| 129 | 129 | return ! empty($country) |
| 130 | - && isset($this->ibanLengthByCountry[$country]) |
|
| 130 | + && isset($this->ibanLengthByCountry[ $country ]) |
|
| 131 | 131 | && $ibanCountryCode === $country; |
| 132 | 132 | } |
| 133 | 133 | |
@@ -138,6 +138,6 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | private function isIbanLengthValid(string $iban, string $ibanCountryCode) |
| 140 | 140 | { |
| 141 | - return strlen($iban) === $this->ibanLengthByCountry[$ibanCountryCode]; |
|
| 141 | + return strlen($iban) === $this->ibanLengthByCountry[ $ibanCountryCode ]; |
|
| 142 | 142 | } |
| 143 | 143 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function callPhoneValidator(): array |
| 31 | 31 | { |
| 32 | - $results = []; |
|
| 32 | + $results = [ ]; |
|
| 33 | 33 | |
| 34 | 34 | $codes = explode(',', $this->code); |
| 35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $methodName = 'validate'.$code; |
| 40 | 40 | |
| 41 | 41 | if (method_exists($this, $methodName)) { |
| 42 | - $results[$code] = $this->{$methodName}(); |
|
| 42 | + $results[ $code ] = $this->{$methodName}(); |
|
| 43 | 43 | } else { |
| 44 | 44 | throw new \BadMethodCallException("Validator method '{$methodName}' does not exist."); |
| 45 | 45 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function validate(string $attribute, mixed $value, Closure $fail): void |
| 19 | 19 | { |
| 20 | - if (! preg_match('/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/', $value)) { |
|
| 20 | + if ( ! preg_match('/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/', $value)) { |
|
| 21 | 21 | $fail('validate.url')->translate(); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | private array $countries; |
| 168 | 168 | |
| 169 | - public function __construct(array|string $countries = []) |
|
| 169 | + public function __construct(array | string $countries = [ ]) |
|
| 170 | 170 | { |
| 171 | 171 | $this->setCountries(func_get_args()); |
| 172 | 172 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | public function validate(string $attribute, mixed $value, Closure $fail): void |
| 183 | 183 | { |
| 184 | - if (! $this->isIbanValid($value)) { |
|
| 184 | + if ( ! $this->isIbanValid($value)) { |
|
| 185 | 185 | $fail('validate.iban')->translate(); |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function validate(string $attribute, mixed $value, Closure $fail): void |
| 19 | 19 | { |
| 20 | - if (! $this->isImeiValid($value)) { |
|
| 20 | + if ( ! $this->isImeiValid($value)) { |
|
| 21 | 21 | $fail('validate.imei')->translate(); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | $digits = str_split($imei); // Get digits |
| 38 | 38 | $imei_last = array_pop($digits); // Remove last digit, and store it |
| 39 | - $log = []; |
|
| 39 | + $log = [ ]; |
|
| 40 | 40 | |
| 41 | 41 | foreach ($digits as $key => $n) { |
| 42 | 42 | if ($key & 1) { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $n = array_sum($double); // Sum double digits |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $log[] = $n; // Append log |
|
| 47 | + $log[ ] = $n; // Append log |
|
| 48 | 48 | } |
| 49 | 49 | $sum = array_sum($log) * 9; // Sum log & multiply by 9 |
| 50 | 50 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function validate(string $attribute, mixed $value, Closure $fail): void |
| 19 | 19 | { |
| 20 | - if (! preg_match('/^[A-Z]{2}[0-9]{2}[A-Z]{2}[0-9]{4}$/', $value)) { |
|
| 20 | + if ( ! preg_match('/^[A-Z]{2}[0-9]{2}[A-Z]{2}[0-9]{4}$/', $value)) { |
|
| 21 | 21 | $fail('validate.car-number')->translate(); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function validate(string $attribute, mixed $value, Closure $fail): void |
| 19 | 19 | { |
| 20 | - if (! preg_match('/\/+$/', $value)) { |
|
| 20 | + if ( ! preg_match('/\/+$/', $value)) { |
|
| 21 | 21 | $fail('validate.slash-end-of-string')->translate(); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | public function validate(string $attribute, mixed $value, Closure $fail): void |
| 19 | 19 | { |
| 20 | - if (! preg_match('/^(?:\p{Ll}+\-)*\p{Ll}+$/u', $value)) { |
|
| 20 | + if ( ! preg_match('/^(?:\p{Ll}+\-)*\p{Ll}+$/u', $value)) { |
|
| 21 | 21 | $fail('validate.kebab-case')->translate(); |
| 22 | 22 | } |
| 23 | 23 | } |