We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Total Complexity | 6 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | class ValidUpload extends BackpackCustomRule |
||
12 | { |
||
13 | use HasFiles; |
||
14 | |||
15 | /** |
||
16 | * Run the validation rule. |
||
17 | * |
||
18 | * @param string $attribute |
||
19 | * @param mixed $value |
||
20 | * @param Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail |
||
21 | * @return void |
||
22 | */ |
||
23 | public function validateRules(string $attribute, mixed $value): array |
||
24 | { |
||
25 | $entry = CrudPanelFacade::getCurrentEntry(); |
||
|
|||
26 | |||
27 | if (! array_key_exists($attribute, $this->data) && $entry) { |
||
28 | return []; |
||
29 | } |
||
30 | |||
31 | $fieldErrors = $this->validateFieldRules($attribute, $value); |
||
32 | |||
33 | if (! empty($value) && ! empty($this->getFileRules())) { |
||
34 | $fileErrors = $this->validateFileRules($attribute, $value); |
||
35 | } |
||
36 | |||
37 | return array_merge($fieldErrors, $fileErrors ?? []); |
||
38 | } |
||
39 | |||
40 | public static function field(string|array|ValidationRule|Rule $rules = []): self |
||
43 | } |
||
44 | } |
||
45 |