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 Cristian
29:54 queued 14:57
created

FileNameGenerator::getExtensionFromFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Backpack\CRUD\app\Library\Uploaders\Support;
4
5
use Backpack\CRUD\app\Library\Uploaders\Support\Interfaces\FileNameGeneratorInterface;
6
use Illuminate\Http\UploadedFile;
7
use Illuminate\Support\Str;
8
9
class FileNameGenerator implements FileNameGeneratorInterface
10
{
11
    public function getName(string|UploadedFile $file): string
12
    {
13
        return $this->getFileName($file).'.'.$this->getExtensionFromFile($file);
14
    }
15
16
    private function getExtensionFromFile(string|UploadedFile $file): string
17
    {
18
        return is_a($file, UploadedFile::class, true) ? $file->extension() : Str::after(mime_content_type($file), '/');
19
    }
20
21
    private function getFileName(string|UploadedFile $file): string
22
    {
23
        if (is_file($file)) {
24
            return Str::of($file->getClientOriginalName())->beforeLast('.')->slug()->append('-'.Str::random(4));
25
        }
26
27
        return Str::random(40);
28
    }
29
}
30