MediaTransformer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Foundation\Transformers;
6
7
use Rinvex\Support\Traits\Escaper;
8
use Spatie\MediaLibrary\Models\Media;
9
use League\Fractal\TransformerAbstract;
10
11
class MediaTransformer extends TransformerAbstract
12
{
13
    use Escaper;
14
15
    /**
16
     * @return array
17
     */
18
    public function transform(Media $media): array
19
    {
20
        return $this->escape([
21
            'id' => (int) $media->getKey(),
22
            'name' => (string) $media->name,
23
            'file_name' => (string) $media->file_name,
24
            'mime_type' => (string) $media->mime_type,
25
            'size' => (string) $media->getHumanReadableSizeAttribute(),
26
            'created_at' => (string) $media->created_at,
27
            'updated_at' => (string) $media->updated_at,
28
            'delete' => (string) route('adminarea.rooms.media.destroy', ['room' => $media->model, 'media' => $media]),
29
        ]);
30
    }
31
}
32