Completed
Push — master ( 204e09...86e349 )
by Freek
04:41 queued 02:13
created

FileIsTooBig::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Spatie\MediaLibrary\Exceptions\FileCannotBeAdded;
4
5
use Spatie\MediaLibrary\Helpers\File;
6
use Spatie\MediaLibrary\Exceptions\FileCannotBeAdded;
7
8
class FileIsTooBig extends FileCannotBeAdded
9
{
10
    public static function create(string $path)
11
    {
12
        $fileSize = File::getHumanReadableSize(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