Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Pull Request — main (#5478)
by Cristian
25:33 queued 14:59
created

ValidUpload::validateRules()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 6
eloc 11
c 1
b 1
f 0
nc 6
nop 2
dl 0
loc 20
rs 9.2222
1
<?php
2
3
namespace Backpack\CRUD\app\Library\Validation\Rules;
4
5
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade;
6
use Illuminate\Contracts\Validation\Rule;
7
use Illuminate\Contracts\Validation\ValidationRule;
8
use Illuminate\Support\Arr;
9
use Illuminate\Support\Str;
10
11
class ValidUpload extends BackpackCustomRule
12
{
13
    /**
14
     * Run the validation rule and return the array of errors.
15
     */
16
    public function validateRules(string $attribute, mixed $value): array
17
    {
18
        $entry = CrudPanelFacade::getCurrentEntry();
0 ignored issues
show
Bug introduced by
The method getCurrentEntry() does not exist on Backpack\CRUD\app\Librar...udPanel\CrudPanelFacade. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        /** @scrutinizer ignore-call */ 
19
        $entry = CrudPanelFacade::getCurrentEntry();
Loading history...
19
20
        if (! Arr::has($this->data, $attribute)) {
21
            $attributeValueForDataArray = null;
22
            $requestAttributeValue = Arr::get($this->data, '_order_'.$attribute);
23
            if ($entry && Str::contains($attribute, '.')) {
24
                $attributeValueForDataArray = $requestAttributeValue;
25
            }
26
            Arr::set($this->data, $attribute, $attributeValueForDataArray);
27
        }
28
29
        $fieldErrors = $this->validateFieldRules($attribute, $value);
30
31
        if (! empty($value) && ! empty($this->getFileRules())) {
32
            $fileErrors = $this->validateFileRules($attribute, $value);
33
        }
34
35
        return array_merge($fieldErrors, $fileErrors ?? []);
36
    }
37
38
    public static function field(string|array|ValidationRule|Rule $rules = []): self
39
    {
40
        return parent::field($rules);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::field($rules) returns the type Backpack\CRUD\app\Librar...ules\BackpackCustomRule which includes types incompatible with the type-hinted return Backpack\CRUD\app\Librar...ation\Rules\ValidUpload.
Loading history...
41
    }
42
}
43