FileIsTooBig::create()   A
last analyzed

Complexity

Conditions 2
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 2
nc 1
nop 2
1
<?php
2
3
namespace Spatie\MediaLibrary\Exceptions\FileCannotBeAdded;
4
5
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded;
6
use Spatie\MediaLibrary\Helpers\File;
7
8
class FileIsTooBig extends FileCannotBeAdded
9
{
10
    public static function create(string $path, int $size = null)
11
    {
12
        $fileSize = File::getHumanReadableSize($size ?: filesize($path));
13
14
        $maxFileSize = File::getHumanReadableSize(config('medialibrary.max_file_size'));
15
16
        return new static("File `{$path}` has a size of {$fileSize} which is greater than the maximum allowed {$maxFileSize}");
17
    }
18
}
19