Message::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 9
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace FaithGen\Messages\Http\Resources;
4
5
use Illuminate\Http\Resources\Json\JsonResource;
6
use InnoFlash\LaraStart\Helper;
7
8
class Message extends JsonResource
9
{
10
    /**
11
     * Transform the resource into an array.
12
     *
13
     * @param  \Illuminate\Http\Request  $request
14
     * @return array
15
     */
16
    public function toArray($request)
17
    {
18
        return [
19
            'id' => $this->id,
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on FaithGen\Messages\Http\Resources\Message. Since you implemented __get, consider adding a @property annotation.
Loading history...
20
            'title' => $this->title,
0 ignored issues
show
Bug Best Practice introduced by
The property title does not exist on FaithGen\Messages\Http\Resources\Message. Since you implemented __get, consider adding a @property annotation.
Loading history...
21
            'message' => $this->message,
0 ignored issues
show
Bug Best Practice introduced by
The property message does not exist on FaithGen\Messages\Http\Resources\Message. Since you implemented __get, consider adding a @property annotation.
Loading history...
22
            'date' => Helper::getDates($this->created_at),
0 ignored issues
show
Bug Best Practice introduced by
The property created_at does not exist on FaithGen\Messages\Http\Resources\Message. Since you implemented __get, consider adding a @property annotation.
Loading history...
23
            'comments' => [
24
                'count' => number_format($this->comments()->count()),
0 ignored issues
show
Bug introduced by
The method comments() does not exist on FaithGen\Messages\Http\Resources\Message. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
                'count' => number_format($this->/** @scrutinizer ignore-call */ comments()->count()),
Loading history...
25
            ],
26
        ];
27
    }
28
}
29