MimeTypeNotAllowed::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Spatie\MediaLibrary\Exceptions\FileCannotBeAdded;
4
5
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded;
6
7
class MimeTypeNotAllowed extends FileCannotBeAdded
8
{
9
    public static function create($file, array $allowedMimeTypes)
10
    {
11
        $mimeType = mime_content_type($file);
12
13
        $allowedMimeTypes = implode(', ', $allowedMimeTypes);
14
15
        return new static("File has a mimetype of {$mimeType}, while only {$allowedMimeTypes} are allowed");
16
    }
17
}
18