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
40:36 queued 25:37
created

ValidUpload::validateRules()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 3 Features 0
Metric Value
cc 7
eloc 11
c 4
b 3
f 0
nc 7
nop 2
dl 0
loc 21
rs 8.8333
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
10
class ValidUpload extends BackpackCustomRule
11
{
12
    /**
13
     * Run the validation rule and return the array of errors.
14
     */
15
    public function validateRules(string $attribute, mixed $value): array
16
    {
17
        $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

17
        /** @scrutinizer ignore-call */ 
18
        $entry = CrudPanelFacade::getCurrentEntry();
Loading history...
18
19
        if (! Arr::has($this->data, $attribute)) {
20
            if ($entry && ! str_contains($attribute, '.')) {
21
                return [];
22
            }
23
            $requestAttributeValue = Arr::get($this->data, '_order_'.$attribute);
24
            $attributeValueForDataArray = $entry ? $requestAttributeValue : null;
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