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 | 36 | if ($instance->validatesArrays()) { |
| 37 | - if (! in_array('array', $instance->getFieldRules())) { |
|
| 37 | + if (!in_array('array', $instance->getFieldRules())) { |
|
| 38 | 38 | $instance->fieldRules[] = 'array'; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | public function getFieldRules(): array |
| 96 | 96 | { |
| 97 | - return tap($this->fieldRules, function ($rule) { |
|
| 97 | + return tap($this->fieldRules, function($rule) { |
|
| 98 | 98 | if (is_a($rule, BackpackCustomRule::class, true)) { |
| 99 | 99 | $rule = $rule->getFieldRules(); |
| 100 | 100 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $rules = explode('|', $rules); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if (! is_array($rules)) { |
|
| 112 | + if (!is_array($rules)) { |
|
| 113 | 113 | $rules = [$rules]; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | protected function ensureValueIsValid($value) |
| 120 | 120 | { |
| 121 | - if ($this->validatesArrays() && ! is_array($value)) { |
|
| 121 | + if ($this->validatesArrays() && !is_array($value)) { |
|
| 122 | 122 | try { |
| 123 | 123 | $value = json_decode($value, true) ?? []; |
| 124 | - } catch(\Exception $e) { |
|
| 124 | + } catch (\Exception $e) { |
|
| 125 | 125 | return false; |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -140,14 +140,13 @@ discard block |
||
| 140 | 140 | $attribute => $rules, |
| 141 | 141 | ], $this->validator->customMessages, $this->validator->customAttributes); |
| 142 | 142 | |
| 143 | - return $validator->errors()->messages()[$attribute] ?? (! empty($validator->errors()->messages()) ? current($validator->errors()->messages()) : []); |
|
| 143 | + return $validator->errors()->messages()[$attribute] ?? (!empty($validator->errors()->messages()) ? current($validator->errors()->messages()) : []); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | protected function getValidationAttributeString(string $attribute) |
| 147 | 147 | { |
| 148 | 148 | return Str::substrCount($attribute, '.') > 1 ? |
| 149 | - Str::before($attribute, '.').'.*.'.Str::afterLast($attribute, '.') : |
|
| 150 | - $attribute; |
|
| 149 | + Str::before($attribute, '.').'.*.'.Str::afterLast($attribute, '.') : $attribute; |
|
| 151 | 150 | } |
| 152 | 151 | |
| 153 | 152 | protected function validateOnSubmit(string $attribute, mixed $value): array |
@@ -155,7 +154,7 @@ discard block |
||
| 155 | 154 | return $this->validateRules($attribute, $value); |
| 156 | 155 | } |
| 157 | 156 | |
| 158 | - protected function validateFieldAndFile(string $attribute, null|array $data = null, array|null $customRules = null): array |
|
| 157 | + protected function validateFieldAndFile(string $attribute, null | array $data = null, array | null $customRules = null): array |
|
| 159 | 158 | { |
| 160 | 159 | $fieldErrors = $this->validateFieldRules($attribute, $data, $customRules); |
| 161 | 160 | |
@@ -167,7 +166,7 @@ discard block |
||
| 167 | 166 | /** |
| 168 | 167 | * Implementation. |
| 169 | 168 | */ |
| 170 | - public function validateFieldRules(string $attribute, null|array|string|UploadedFile $data = null, array|null $customRules = null): array |
|
| 169 | + public function validateFieldRules(string $attribute, null | array | string | UploadedFile $data = null, array | null $customRules = null): array |
|
| 171 | 170 | { |
| 172 | 171 | $data = $data ?? $this->data; |
| 173 | 172 | $validationRuleAttribute = $this->getValidationAttributeString($attribute); |
@@ -176,16 +175,16 @@ discard block |
||
| 176 | 175 | return $this->validateAndGetErrors($validationRuleAttribute, $data, $customRules ?? $this->getFieldRules()); |
| 177 | 176 | } |
| 178 | 177 | |
| 179 | - protected function prepareValidatorData(array|string|UploadedFile $data, string $attribute): array |
|
| 178 | + protected function prepareValidatorData(array | string | UploadedFile $data, string $attribute): array |
|
| 180 | 179 | { |
| 181 | - if ($this->validatesArrays() && is_array($data) && ! Str::contains($attribute, '.')) { |
|
| 180 | + if ($this->validatesArrays() && is_array($data) && !Str::contains($attribute, '.')) { |
|
| 182 | 181 | return Arr::has($data, $attribute) ? $data : [$attribute => $data]; |
| 183 | 182 | } |
| 184 | 183 | |
| 185 | 184 | if (Str::contains($attribute, '.')) { |
| 186 | 185 | $validData = []; |
| 187 | 186 | |
| 188 | - Arr::set($validData, $attribute, ! is_array($data) ? $data : Arr::get($data, $attribute)); |
|
| 187 | + Arr::set($validData, $attribute, !is_array($data) ? $data : Arr::get($data, $attribute)); |
|
| 189 | 188 | |
| 190 | 189 | return $validData; |
| 191 | 190 | } |
@@ -199,7 +198,7 @@ discard block |
||
| 199 | 198 | $items = is_array($items) ? $items : [$items]; |
| 200 | 199 | $validationRuleAttribute = $this->getValidationAttributeString($attribute); |
| 201 | 200 | $filesToValidate = Arr::get($items, $attribute); |
| 202 | - $filesToValidate = array_filter($filesToValidate ?? [], function ($item) { |
|
| 201 | + $filesToValidate = array_filter($filesToValidate ?? [], function($item) { |
|
| 203 | 202 | return $item instanceof UploadedFile; |
| 204 | 203 | }); |
| 205 | 204 | |