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
39:53 queued 25:09
created

HandleFileNaming::getFileName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Backpack\CRUD\app\Library\Uploaders\Support\Traits;
4
5
use Backpack\CRUD\app\Library\Uploaders\Support\Interfaces\FileNameGeneratorInterface;
6
use Illuminate\Http\UploadedFile;
7
use Symfony\Component\HttpFoundation\File\File;
8
9
trait HandleFileNaming
10
{
11
    public mixed $fileNamer = null;
12
13
    public function getFileName(string|UploadedFile|File $file): string
14
    {
15
        return is_callable($this->fileNamer) ? ($this->fileNamer)($file, $this) : $this->fileNamer->getName($file);
16
    }
17
18
    private function getFileNameGeneratorInstance(?string $fileNameGenerator): FileNameGeneratorInterface
19
    {
20
        $fileGeneratorClass = $fileNameGenerator ?? config('backpack.crud.file_name_generator');
21
22
        if (! class_exists($fileGeneratorClass)) {
23
            throw new \Exception("The file name generator class [{$fileGeneratorClass}] does not exist.");
24
        }
25
26
        if (! in_array(FileNameGeneratorInterface::class, class_implements($fileGeneratorClass, false))) {
27
            throw new \Exception("The file name generator class [{$fileGeneratorClass}] must implement the [".FileNameGeneratorInterface::class.'] interface.');
28
        }
29
30
        return new $fileGeneratorClass();
31
    }
32
}
33