Passed
Push — master ( 0c5e09...b94ee9 )
by Arthur
08:40 queued 02:13
created

NotificationResource::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 1
dl 0
loc 12
ccs 9
cts 9
cp 1
crap 2
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 2
    public function toArray($request)
24
    {
25 2
        $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 2
            '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 2
            'title' => $notification->title,
29 2
            'message' => $notification->message,
30 2
            'target' => $notification->target,
31 2
            'tag' => $notification->tag,
32 2
            '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 2
        return $resource;
35
    }
36
}
37