AttributeTransformer::transform()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 13
rs 9.8333
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Attributes\Transformers\Adminarea;
6
7
use Rinvex\Support\Traits\Escaper;
8
use Cortex\Attributes\Models\Attribute;
9
use League\Fractal\TransformerAbstract;
10
11
class AttributeTransformer extends TransformerAbstract
12
{
13
    use Escaper;
14
15
    /**
16
     * @return array
17
     */
18
    public function transform(Attribute $attribute): array
19
    {
20
        return $this->escape([
21
            'id' => (string) $attribute->getRouteKey(),
22
            'name' => (string) $attribute->name,
23
            'type' => (string) $attribute->type,
24
            'group' => (string) $attribute->group,
25
            'is_collection' => (bool) $attribute->is_collection,
26
            'is_required' => (bool) $attribute->is_required,
27
            'created_at' => (string) $attribute->created_at,
28
            'updated_at' => (string) $attribute->updated_at,
29
        ]);
30
    }
31
}
32