Passed
Push — master ( e5b31a...cf340d )
by Arthur
04:48
created

NotificationResource::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 1
dl 0
loc 12
ccs 0
cts 12
cp 0
crap 6
rs 9.9666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 14.10.18
6
 * Time: 23:31
7
 */
8
9
namespace Foundation\Resources;
10
11
use Illuminate\Http\Resources\Json\JsonResource;
12
13
class NotificationResource extends JsonResource
14
{
15
16
17
    /**
18
     * Transform the resource into an array.
19
     *
20
     * @param  \Illuminate\Http\Request $request
21
     * @return array
22
     */
23
    public function toArray($request)
24
    {
25
        $notification = (object)$this->data;
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist on Foundation\Resources\NotificationResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
26
        $resource = [
27
            'id' => $this->getKey(),
0 ignored issues
show
Bug introduced by
The method getKey() does not exist on Foundation\Resources\NotificationResource. 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

27
            'id' => $this->/** @scrutinizer ignore-call */ getKey(),
Loading history...
28
            'title' => $notification->title,
29
            'message' => $notification->message,
30
            'target' => $notification->target,
31
            'tag' => $notification->tag,
32
            'is_read' => isset($this->read_at) ? true : false
0 ignored issues
show
Bug Best Practice introduced by
The property read_at does not exist on Foundation\Resources\NotificationResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
33
        ];
34
        return $resource;
35
    }
36
}
37