Completed
Push — develop ( bb4908...cd07ae )
by Abdelrahman
29:11
created

MediaTransformer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 19
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 Spatie\MediaLibrary\Models\Media;
8
use League\Fractal\TransformerAbstract;
9
10
class MediaTransformer extends TransformerAbstract
11
{
12
    /**
13
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,integer|string>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
14
     */
15
    public function transform(Media $media)
16
    {
17
        return [
18
            'id' => (int) $media->id,
19
            'name' => (string) $media->name,
20
            'file_name' => (string) $media->file_name,
21
            'mime_type' => (string) $media->mime_type,
22
            'size' => (string) $media->getHumanReadableSizeAttribute(),
23
            'created_at' => (string) $media->created_at,
24
            'updated_at' => (string) $media->updated_at,
25
            'delete' => (string) route('adminarea.rooms.media.delete', ['room' => $media->model, 'media' => $media]),
26
        ];
27
    }
28
}
29