Passed
Push — master ( f218e6...f51c1b )
by Arthur
04:59
created

NotificationResource::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 1
dl 0
loc 13
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 Modules\Notification\Resources;
10
11
use Illuminate\Http\Resources\Json\JsonResource;
12
13
class NotificationResource extends JsonResource
14
{
15
    /**
16
     * Transform the resource into an array.
17
     *
18
     * @param \Illuminate\Http\Request $request
19
     *
20
     * @return array
21
     */
22
    public function toArray($request)
23
    {
24
        $notification = (object) $this->data;
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist on Modules\Notification\Res...es\NotificationResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
25
        $resource = [
26
            'id'      => $this->getKey(),
0 ignored issues
show
Bug introduced by
The method getKey() does not exist on Modules\Notification\Res...es\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

26
            'id'      => $this->/** @scrutinizer ignore-call */ getKey(),
Loading history...
27
            'title'   => $notification->title,
28
            'message' => $notification->message,
29
            'target'  => $notification->target,
30
            'tag'     => $notification->tag,
31
            '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 Modules\Notification\Res...es\NotificationResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
32
        ];
33
34
        return $resource;
35
    }
36
}
37