We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public bool $implicit = true; |
| 30 | 30 | |
| 31 | - public static function field(string|array|ValidationRule|Rule $rules = []): self |
|
| 31 | + public static function field(string | array | ValidationRule | Rule $rules = []): self |
|
| 32 | 32 | { |
| 33 | 33 | $instance = new static(); |
| 34 | 34 | $instance->fieldRules = self::getRulesAsArray($rules); |
| 35 | 35 | |
| 36 | - if($instance->validatesArrays()) { |
|
| 37 | - if (! in_array('array', $instance->getFieldRules())) { |
|
| 36 | + if ($instance->validatesArrays()) { |
|
| 37 | + if (!in_array('array', $instance->getFieldRules())) { |
|
| 38 | 38 | $instance->fieldRules[] = 'array'; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $instance = new static(); |
| 45 | 45 | $instance->fieldRules = self::getRulesAsArray($rules); |
| 46 | 46 | |
| 47 | - if (! in_array('array', $instance->getFieldRules())) { |
|
| 47 | + if (!in_array('array', $instance->getFieldRules())) { |
|
| 48 | 48 | $instance->fieldRules[] = 'array'; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | public function getFieldRules(): array |
| 105 | 105 | { |
| 106 | - return tap($this->fieldRules, function ($rule) { |
|
| 106 | + return tap($this->fieldRules, function($rule) { |
|
| 107 | 107 | if (is_a($rule, BackpackCustomRule::class, true)) { |
| 108 | 108 | $rule = $rule->getFieldRules(); |
| 109 | 109 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $rules = explode('|', $rules); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if (! is_array($rules)) { |
|
| 121 | + if (!is_array($rules)) { |
|
| 122 | 122 | $rules = [$rules]; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | protected function ensureValueIsValid($value) |
| 129 | 129 | { |
| 130 | - if($this->validatesArrays() && ! is_array($value)) { |
|
| 130 | + if ($this->validatesArrays() && !is_array($value)) { |
|
| 131 | 131 | try { |
| 132 | 132 | $value = json_decode($value, true) ?? []; |
| 133 | - } catch(\Exception $e) { |
|
| 133 | + } catch (\Exception $e) { |
|
| 134 | 134 | return false; |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -154,8 +154,7 @@ discard block |
||
| 154 | 154 | protected function getValidationAttributeString(string $attribute) |
| 155 | 155 | { |
| 156 | 156 | return Str::substrCount($attribute, '.') > 1 ? |
| 157 | - Str::before($attribute, '.').'.*.'.Str::afterLast($attribute, '.') : |
|
| 158 | - $attribute; |
|
| 157 | + Str::before($attribute, '.').'.*.'.Str::afterLast($attribute, '.') : $attribute; |
|
| 159 | 158 | } |
| 160 | 159 | |
| 161 | 160 | protected function validateOnSubmit(string $attribute, mixed $value): array |
@@ -163,7 +162,7 @@ discard block |
||
| 163 | 162 | return $this->validateRules($attribute, $value); |
| 164 | 163 | } |
| 165 | 164 | |
| 166 | - protected function validateFieldAndFile(string $attribute, null|array $data = null, array|null $customRules = null): array |
|
| 165 | + protected function validateFieldAndFile(string $attribute, null | array $data = null, array | null $customRules = null): array |
|
| 167 | 166 | { |
| 168 | 167 | $fieldErrors = $this->validateFieldRules($attribute, $data, $customRules); |
| 169 | 168 | $fileErrors = $this->validateFileRules($attribute, $data); |
@@ -174,7 +173,7 @@ discard block |
||
| 174 | 173 | /** |
| 175 | 174 | * Implementation. |
| 176 | 175 | */ |
| 177 | - public function validateFieldRules(string $attribute, null|array|UploadedFile $data = null, array|null $customRules = null): array |
|
| 176 | + public function validateFieldRules(string $attribute, null | array | UploadedFile $data = null, array | null $customRules = null): array |
|
| 178 | 177 | { |
| 179 | 178 | $data = $data ?? $this->data; |
| 180 | 179 | $validationRuleAttribute = $this->getValidationAttributeString($attribute); |
@@ -184,10 +183,10 @@ discard block |
||
| 184 | 183 | return $this->validateAndGetErrors($validationRuleAttribute, $data, $customRules ?? $this->getFieldRules()); |
| 185 | 184 | } |
| 186 | 185 | |
| 187 | - protected function prepareValidatorData(array|UploadedFile $data, string $attribute): array |
|
| 186 | + protected function prepareValidatorData(array | UploadedFile $data, string $attribute): array |
|
| 188 | 187 | { |
| 189 | 188 | |
| 190 | - if($this->validatesArrays() && is_array($data)) { |
|
| 189 | + if ($this->validatesArrays() && is_array($data)) { |
|
| 191 | 190 | return Arr::has($data, $attribute) ? $data : [$attribute => Arr::get($data, $attribute)]; |
| 192 | 191 | } |
| 193 | 192 | return [$attribute => $data]; |
@@ -201,13 +200,13 @@ discard block |
||
| 201 | 200 | $errors = []; |
| 202 | 201 | // we validate each file individually to avoid returning messages like: `field.0` is not a pdf. |
| 203 | 202 | foreach ($items as $sentFiles) { |
| 204 | - if(!is_array($sentFiles)) { |
|
| 203 | + if (!is_array($sentFiles)) { |
|
| 205 | 204 | try { |
| 206 | 205 | if (is_file($sentFiles)) { |
| 207 | 206 | $errors[] = $this->validateAndGetErrors($attribute, [$attribute => $sentFiles], $this->getFileRules()); |
| 208 | 207 | } |
| 209 | 208 | continue; |
| 210 | - }catch(\Exception) { |
|
| 209 | + } catch (\Exception) { |
|
| 211 | 210 | $errors[] = 'Unknown datatype, aborting upload process.'; |
| 212 | 211 | break; |
| 213 | 212 | } |
@@ -207,7 +207,7 @@ |
||
| 207 | 207 | $errors[] = $this->validateAndGetErrors($attribute, [$attribute => $sentFiles], $this->getFileRules()); |
| 208 | 208 | } |
| 209 | 209 | continue; |
| 210 | - }catch(\Exception) { |
|
| 210 | + } catch(\Exception) { |
|
| 211 | 211 | $errors[] = 'Unknown datatype, aborting upload process.'; |
| 212 | 212 | break; |
| 213 | 213 | } |