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
Push — add-method-to-get-ajax-uploade... ( 4a3e5a...2230c6 )
by Pedro
14:58
created

ValidUploadMultiple::validateRules()   A

Complexity

Conditions 6
Paths 16

Size

Total Lines 29
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
cc 6
eloc 14
c 3
b 1
f 0
nc 16
nop 2
dl 0
loc 29
rs 9.2222
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
            
18
            $this->data[$attribute] = [];
19
            $value = [];
20
        }
21
22
        $previousValues = $entry?->{$attribute} ?? [];
23
        if (is_string($previousValues)) {
24
            $previousValues = json_decode($previousValues, true) ?? [];
25
        }
26
27
        $value = array_merge($previousValues, $value);
28
29
        if ($entry) {
30
            $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

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