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 | 33 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | class ValidUpload extends BackpackCustomRule |
||
13 | { |
||
14 | use HasFiles; |
||
15 | |||
16 | /** |
||
17 | * Run the validation rule. |
||
18 | * |
||
19 | * @param string $attribute |
||
20 | * @param mixed $value |
||
21 | * @param Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail |
||
22 | * @return void |
||
23 | */ |
||
24 | public function validateRules(string $attribute, mixed $value): array |
||
25 | { |
||
26 | $entry = CrudPanelFacade::getCurrentEntry(); |
||
|
|||
27 | |||
28 | if (! array_key_exists($attribute, $this->data) && $entry) { |
||
29 | return []; |
||
30 | } |
||
31 | |||
32 | $fieldErrors = $this->validateFieldRules($attribute, $value); |
||
33 | |||
34 | if (! empty($value) && ! empty($this->getFileRules())) { |
||
35 | $fileErrors = $this->validateFileRules($attribute, $value); |
||
36 | } |
||
37 | |||
38 | return array_merge($fieldErrors, $fileErrors ?? []); |
||
39 | |||
40 | } |
||
41 | |||
42 | public static function field(string|array|ValidationRule|Rule $rules = []): self |
||
45 | } |
||
46 | } |
||
47 |