Passed
Pull Request — main (#62)
by Tan
03:17
created

CategoryResource::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
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\Category;
4
5
use CSlant\Blog\Core\Models\Category;
6
use CSlant\Blog\Core\Models\Slug;
7
use Illuminate\Http\Resources\Json\JsonResource;
8
9
/**
10
 * @mixin Category
11
 */
12
class CategoryResource extends JsonResource
13
{
14
    /**
15
     * @param $request
16
     *
17
     * @return array<string, mixed>
18
     */
19
    public function toArray($request): array
20
    {
21
        return [
22
            'id' => $this->id,
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on CSlant\Blog\Api\Http\Res...tegory\CategoryResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
23
            'name' => $this->name,
0 ignored issues
show
Bug Best Practice introduced by
The property name does not exist on CSlant\Blog\Api\Http\Res...tegory\CategoryResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
24
            'slug' => $this->slug instanceof Slug ? $this->slug->key : $this->slug,
0 ignored issues
show
Bug Best Practice introduced by
The property slug does not exist on CSlant\Blog\Api\Http\Res...tegory\CategoryResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
25
            'url' => $this->url,
0 ignored issues
show
Bug Best Practice introduced by
The property url does not exist on CSlant\Blog\Api\Http\Res...tegory\CategoryResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
26
            'icon' => $this->icon,
0 ignored issues
show
Bug Best Practice introduced by
The property icon does not exist on CSlant\Blog\Api\Http\Res...tegory\CategoryResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
27
            'description' => $this->description,
0 ignored issues
show
Bug Best Practice introduced by
The property description does not exist on CSlant\Blog\Api\Http\Res...tegory\CategoryResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
28
        ];
29
    }
30
}
31