Completed
Push — master ( 7f96cd...27908d )
by Freek
09:27
created

MediaCannotBeDeleted::doesNotBelongToModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Spatie\Medialibrary\Exceptions;
4
5
use Exception;
6
use Illuminate\Database\Eloquent\Model;
7
use Spatie\MediaLibrary\Media;
8
9
class MediaCannotBeDeleted extends Exception
10
{
11
    public static function doesNotBelongToModel(Media $media, Model $model)
12
    {
13
        $modelClass = get_class($model);
14
15
        return new static("Media with id {$media->getKey()} cannot be deleted because it does not belong to model {$modelClass} with id {$model->id}");
16
    }
17
}
18