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 (#5440)
by Cristian
26:23 queued 11:28
created

ValidUploadMultiple::validateRules()   B

Complexity

Conditions 7
Paths 24

Size

Total Lines 32
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 7
eloc 17
c 2
b 1
f 0
nc 24
nop 2
dl 0
loc 32
rs 8.8333
1
<?php
2
3
namespace Backpack\CRUD\app\Library\Validation\Rules;
4
5
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade;
6
7
class ValidUploadMultiple extends ValidFileArray
8
{
9
    public function validateRules(string $attribute, mixed $value): array
10
    {
11
        $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

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

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