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 (#4988)
by Pedro
40:53 queued 25:51
created

SingleFile::uploadFile()   B

Complexity

Conditions 8
Paths 4

Size

Total Lines 24
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 12
nc 4
nop 2
dl 0
loc 24
rs 8.4444
c 0
b 0
f 0
1
<?php
2
3
namespace Backpack\CRUD\app\Library\CrudPanel\Uploads\Uploaders;
4
5
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Support\Facades\Storage;
8
9
class SingleFile extends Uploader
10
{
11
    public function saveRepeatableFile(Model $entry, $values = null)
12
    {
13
        $orderedFiles = $this->getFileOrderFromRequest();
14
15
        $previousFiles = $this->getPreviousRepeatableValues($entry);
16
17
        foreach ($values as $row => $file) {
18
            if ($file && is_file($file) && $file->isValid()) {
19
                $fileName = $this->getFileNameWithExtension($file);
20
21
                $file->storeAs($this->path, $fileName, $this->disk);
22
                $orderedFiles[$row] = $this->path.$fileName;
23
24
                continue;
25
            }
26
        }
27
28
        foreach ($previousFiles as $row => $file) {
29
            if ($file && ! isset($orderedFiles[$row])) {
30
                $orderedFiles[$row] = null;
31
                Storage::disk($this->disk)->delete($file);
32
            }
33
        }
34
35
        return $orderedFiles;
36
    }
37
38
    public function uploadFile(Model $entry, $value = null)
39
    {
40
        $value = $value ?? CrudPanelFacade::getRequest()->file($this->name);
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

40
        $value = $value ?? CrudPanelFacade::/** @scrutinizer ignore-call */ getRequest()->file($this->name);
Loading history...
41
42
        $previousFile = $entry->getOriginal($this->name);
43
44
        if ($value && is_file($value) && $value->isValid()) {
45
            if ($previousFile) {
46
                Storage::disk($this->disk)->delete($previousFile);
47
            }
48
            $fileName = $this->getFileNameWithExtension($value);
49
50
            $value->storeAs($this->path, $fileName, $this->disk);
51
52
            return $this->path.$fileName;
53
        }
54
55
        if (! $value && CrudPanelFacade::getRequest()->has($this->name) && $previousFile) {
56
            Storage::disk($this->disk)->delete($previousFile);
57
58
            return null;
59
        }
60
61
        return $previousFile;
62
    }
63
}
64