Passed
Pull Request — main (#31)
by Tan
14:50 queued 35s
created

PostResource   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 2
eloc 13
c 3
b 1
f 2
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 14 2
1
<?php
2
3
namespace CSlant\Blog\Api\Http\Resources;
4
5
use Botble\Media\Facades\RvMedia;
0 ignored issues
show
Bug introduced by
The type Botble\Media\Facades\RvMedia was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use CSlant\Blog\Core\Models\Post;
7
use Illuminate\Http\Resources\Json\JsonResource;
8
9
/**
10
 * @mixin Post
11
 */
12
class PostResource 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\Resources\PostResource. 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\Resources\PostResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
24
            'slug' => $this->slug,
0 ignored issues
show
Bug Best Practice introduced by
The property slug does not exist on CSlant\Blog\Api\Http\Resources\PostResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
25
            'description' => $this->description,
0 ignored issues
show
Bug Best Practice introduced by
The property description does not exist on CSlant\Blog\Api\Http\Resources\PostResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
26
            'content' => $this->content,
0 ignored issues
show
Bug Best Practice introduced by
The property content does not exist on CSlant\Blog\Api\Http\Resources\PostResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
27
            'image' => $this->image ? RvMedia::url($this->image) : null,
0 ignored issues
show
Bug Best Practice introduced by
The property image does not exist on CSlant\Blog\Api\Http\Resources\PostResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
28
            'categories' => CategoryResource::collection($this->categories),
0 ignored issues
show
Bug Best Practice introduced by
The property categories does not exist on CSlant\Blog\Api\Http\Resources\PostResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
29
            'tags' => TagResource::collection($this->tags),
0 ignored issues
show
Bug Best Practice introduced by
The property tags does not exist on CSlant\Blog\Api\Http\Resources\PostResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
30
            'author' => AuthorResource::make($this->author),
0 ignored issues
show
Bug Best Practice introduced by
The property author does not exist on CSlant\Blog\Api\Http\Resources\PostResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
31
            'created_at' => $this->created_at,
0 ignored issues
show
Bug Best Practice introduced by
The property created_at does not exist on CSlant\Blog\Api\Http\Resources\PostResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
32
            'updated_at' => $this->updated_at,
0 ignored issues
show
Bug Best Practice introduced by
The property updated_at does not exist on CSlant\Blog\Api\Http\Resources\PostResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
33
        ];
34
    }
35
}
36