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 (#5440)
by Cristian
30:05 queued 14:48
created

ValidUploadMultiple::validate()   B

Complexity

Conditions 8
Paths 25

Size

Total Lines 44
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 23
c 1
b 0
f 0
nc 25
nop 3
dl 0
loc 44
rs 8.4444
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\ValidateArrayContract;
7
8
class ValidUploadMultiple extends BackpackCustomRule implements ValidateArrayContract
9
{
10
    public function validateRules(string $attribute, mixed $value): array
11
    {
12
        $entry = CrudPanelFacade::getCurrentEntry() !== false ? CrudPanelFacade::getCurrentEntry() : null;
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

12
        $entry = CrudPanelFacade::/** @scrutinizer ignore-call */ getCurrentEntry() !== false ? CrudPanelFacade::getCurrentEntry() : null;
Loading history...
13
14
        // `upload_multiple` sends [[0 => null]] when user doesn't upload anything
15
        // assume that nothing changed on field so nothing is sent on the request.
16
        if (count($value) === 1 && empty($value[0])) {
17
            $this->data[$attribute] = [];
18
            $value = [];
19
        }
20
21
        $previousValues = $entry?->{$attribute} ?? [];
22
        if (is_string($previousValues)) {
23
            $previousValues = json_decode($previousValues, true) ?? [];
24
        }
25
26
        $value = array_merge($previousValues, $value);
27
28
        if ($entry) {
29
            $filesDeleted = CrudPanelFacade::getRequest()->input('clear_'.$attribute) ?? [];
0 ignored issues
show
Bug introduced by
The method getRequest() 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

29
            $filesDeleted = CrudPanelFacade::/** @scrutinizer ignore-call */ getRequest()->input('clear_'.$attribute) ?? [];
Loading history...
30
31
            $data = $this->data;
32
            $data[$attribute] = array_diff($value, $filesDeleted);
33
34
            return $this->validateFieldAndFile($attribute, $data);
35
        }
36
37
        return $this->validateFieldAndFile($attribute, $value);
38
    }
39
}
40