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

Test Failed
Pull Request — main (#5478)
by Cristian
30:16 queued 15:12
created

ValidUpload   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
c 0
b 0
f 0
dl 0
loc 33
rs 10
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A field() 0 3 1
A validateRules() 0 21 6
1
<?php
2
3
namespace Backpack\CRUD\app\Library\Validation\Rules;
4
5
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade;
6
use Backpack\CRUD\app\Library\Validation\Rules\Support\HasFiles;
7
use Illuminate\Contracts\Validation\Rule;
8
use Illuminate\Contracts\Validation\ValidationRule;
9
use Illuminate\Support\Arr;
10
use Illuminate\Support\Str;
11
12
class ValidUpload extends BackpackCustomRule
13
{
14
    use HasFiles;
15
16
    /**
17
     * Run the validation rule and return the array of errors.
18
     */
19
    public function validateRules(string $attribute, mixed $value): array
20
    {
21
        $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

21
        /** @scrutinizer ignore-call */ 
22
        $entry = CrudPanelFacade::getCurrentEntry();
Loading history...
22
23
        if (! array_key_exists($attribute, $this->data)) {
24
            $requestAttribute = Arr::get($this->data, '_order_'.$attribute);
25
26
            if ($entry && Arr::get($entry->{Str::before($attribute, '.')}, Str::after($attribute, '.')) === $requestAttribute) {
27
                return [];
28
            }
29
            // set the empty attribute in data
30
            Arr::set($this->data, $attribute, null);
31
        }
32
33
        $fieldErrors = $this->validateFieldRules($attribute, $value);
34
35
        if (! empty($value) && ! empty($this->getFileRules())) {
36
            $fileErrors = $this->validateFileRules($attribute, $value);
37
        }
38
39
        return array_merge($fieldErrors, $fileErrors ?? []);
40
    }
41
42
    public static function field(string|array|ValidationRule|Rule $rules = []): self
43
    {
44
        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...
45
    }
46
}
47