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::getFileNameGeneratorInstance()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 13
rs 10
c 0
b 0
f 0
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