FileIsTooBig   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
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 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