Completed
Pull Request — master (#468)
by
unknown
13:15
created

FileIsTooBig   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 11
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 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