TagResource::toArray()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CSlant\Blog\Api\Http\Resources\Tag;
4
5
use CSlant\Blog\Core\Models\Slug;
6
use CSlant\Blog\Core\Models\Tag;
7
use Illuminate\Http\Resources\Json\JsonResource;
8
9
/**
10
 * @mixin Tag
11
 */
12
class TagResource extends JsonResource
13
{
14
    /**
15
     * @param $request
16
     *
17
     * @return array<string, mixed>
18
     */
19
    public function toArray($request): array
20
    {
21
        /** @var Tag $this */
22
        return [
23
            'id' => $this->id,
24
            'name' => $this->name,
25
            '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...
26
            'description' => $this->description,
27
            'posts_count' => $this->posts_count,
28
        ];
29
    }
30
}
31