CategoryResource::toArray()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
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