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
Push — add-method-to-get-ajax-uploade... ( 20693f...16244a )
by Pedro
11:40
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
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