NotificationTransformer::transformResource()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 0
loc 11
ccs 0
cts 10
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 29.10.18
6
 * Time: 12:40.
7
 */
8
9
namespace Modules\Notification\Transformers;
10
11
use Foundation\Abstracts\Transformers\Transformer;
12
use Illuminate\Notifications\DatabaseNotification;
13
14
class NotificationTransformer extends Transformer
15
{
16
    public function transformResource(DatabaseNotification $notification)
17
    {
18
        $notificationData = (object) $notification->data;
19
20
        return [
21
            'id'      => $notification->getKey(),
22
            'title'   => $notificationData->title,
23
            'message' => $notificationData->message,
24
            'target'  => $notificationData->target,
25
            'tag'     => $notificationData->tag,
26
            'is_read' => isset($notification->read_at) ? true : false,
27
        ];
28
    }
29
}
30