Passed
Push — main ( 18250b...f71c86 )
by Tan
02:53 queued 25s
created

ListCategoryResource   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 9
c 1
b 0
f 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 12 1
1
<?php
2
3
namespace CSlant\Blog\Api\Http\Resources;
4
5
use CSlant\Blog\Core\Http\Resources\Base\BaseListCategoryResource;
6
use CSlant\Blog\Core\Models\Category;
7
use Illuminate\Http\Request;
8
9
/**
10
 * @mixin Category
11
 */
12
class ListCategoryResource extends BaseListCategoryResource
13
{
14
    /**
15
     * @param  Request  $request
16
     *
17
     * @return array<string, mixed>
18
     */
19
    public function toArray($request): array
20
    {
21
        /** @var Category $this */
22
23
        return [
24
            'id' => $this->id,
25
            'name' => $this->name,
26
            'slug' => $this->slug,
27
            'icon' => $this->icon,
28
            'description' => $this->description,
29
            'children' => CategoryResource::collection($this->children),
30
            'parent' => new CategoryResource($this->parent),
31
        ];
32
    }
33
}
34