CategoryResource   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 10 2
1
<?php
2
3
namespace CSlant\Blog\Api\Http\Resources\Category;
4
5
use CSlant\Blog\Core\Models\Category;
6
use CSlant\Blog\Core\Models\Slug;
7
use Illuminate\Http\Request;
8
use Illuminate\Http\Resources\Json\JsonResource;
9
10
/**
11
 * @mixin Category
12
 */
13
class CategoryResource extends JsonResource
14
{
15
    /**
16
     * @param  Request  $request
17
     *
18
     * @return array<string, mixed>
19
     */
20
    public function toArray(Request $request): array
21
    {
22
        /** @var Category $this */
23
        return [
24
            'id' => $this->id,
25
            'name' => $this->name,
26
            'slug' => $this->slug instanceof Slug ? $this->slug->key : $this->slug,
0 ignored issues
show
introduced by
$this->slug is always a sub-type of CSlant\Blog\Core\Models\Slug.
Loading history...
27
            // 'url' => $this->url,
28
            'icon' => $this->icon,
29
            'description' => $this->description,
30
        ];
31
    }
32
}
33