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 — v6-livewire-widget ( bb8951...53543e )
by Pedro
14:58
created

SingleFile::uploadRepeatableFiles()   B

Complexity

Conditions 8
Paths 9

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 12
nc 9
nop 3
dl 0
loc 22
rs 8.4444
c 0
b 0
f 0
1
<?php
2
3
namespace Backpack\CRUD\app\Library\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 uploadFiles(Model $entry, $value = null)
12
    {
13
        $value = $value ?? CrudPanelFacade::getRequest()->file($this->getName());
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

13
        $value = $value ?? CrudPanelFacade::/** @scrutinizer ignore-call */ getRequest()->file($this->getName());
Loading history...
14
        $previousFile = $this->getPreviousFiles($entry);
15
16
        if ($value && is_file($value) && $value->isValid()) {
17
            if ($previousFile) {
18
                Storage::disk($this->getDisk())->delete($previousFile);
19
            }
20
            $fileName = $this->getFileName($value);
21
            $value->storeAs($this->getPath(), $fileName, $this->getDisk());
22
23
            return $this->getPath().$fileName;
24
        }
25
26
        if (! $value && CrudPanelFacade::getRequest()->has($this->getRepeatableContainerName() ?? $this->getName()) && $previousFile) {
27
            Storage::disk($this->getDisk())->delete($previousFile);
28
29
            return null;
30
        }
31
32
        return $previousFile;
33
    }
34
35
    public function uploadRepeatableFiles($values, $previousRepeatableValues, $entry = null)
0 ignored issues
show
Unused Code introduced by
The parameter $entry is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

35
    public function uploadRepeatableFiles($values, $previousRepeatableValues, /** @scrutinizer ignore-unused */ $entry = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        $orderedFiles = $this->getFileOrderFromRequest();
38
39
        foreach ($values as $row => $file) {
40
            if ($file && is_file($file) && $file->isValid()) {
41
                $fileName = $this->getFileName($file);
42
                $file->storeAs($this->getPath(), $fileName, $this->getDisk());
43
                $orderedFiles[$row] = $this->getPath().$fileName;
44
45
                continue;
46
            }
47
        }
48
49
        foreach ($previousRepeatableValues as $row => $file) {
50
            if ($file && ! isset($orderedFiles[$row])) {
51
                $orderedFiles[$row] = null;
52
                Storage::disk($this->getDisk())->delete($file);
53
            }
54
        }
55
56
        return $orderedFiles;
57
    }
58
}
59