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

NotificationResource   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 13 2
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