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 Pedro
27:49 queued 12:44
created

ValidUpload   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 6
Bugs 5 Features 0
Metric Value
eloc 16
c 6
b 5
f 0
dl 0
loc 35
rs 10
wmc 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A field() 0 3 1
B validateRules() 0 25 9
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 (! array_key_exists($attribute, $this->data) && $entry) {
21
            if (str_contains($attribute, '.') && get_class($entry) === get_class(CrudPanelFacade::getModel())) {
0 ignored issues
show
Bug introduced by
The method getModel() 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
            if (str_contains($attribute, '.') && get_class($entry) === get_class(CrudPanelFacade::/** @scrutinizer ignore-call */ getModel())) {
Loading history...
22
                $previousValue = Arr::get($this->data, '_order_'.Str::before($attribute, '.'));
23
                $previousValue = Arr::get($previousValue, Str::after($attribute, '.'));
24
            } else {
25
                $previousValue = Arr::get($entry, $attribute);
26
            }
27
28
            if ($previousValue && empty($value)) {
29
                return [];
30
            }
31
            Arr::set($this->data, $attribute, $previousValue ?? $value);
32
        }
33
34
        $fieldErrors = $this->validateFieldRules($attribute, $value);
35
36
        if (! empty($value) && ! empty($this->getFileRules())) {
37
            $fileErrors = $this->validateFileRules($attribute, $value);
38
        }
39
40
        return array_merge($fieldErrors, $fileErrors ?? []);
41
    }
42
43
    public static function field(string|array|ValidationRule|Rule $rules = []): self
44
    {
45
        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...
46
    }
47
}
48