Passed
Push — master ( 802ddf...d5fac0 )
by Arthur
13:53
created

NotificationTransformer::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
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 2
    public function transformResource(DatabaseNotification $notification)
17
    {
18 2
        $notificationData = (object)$notification->data;
19
        return [
20 2
            'id' => $notification->getKey(),
21 2
            'title' => $notificationData->title,
22 2
            'message' => $notificationData->message,
23 2
            'target' => $notificationData->target,
24 2
            'tag' => $notificationData->tag,
25 2
            'is_read' => isset($notification->read_at) ? true : false,
26
        ];
27
    }
28
}
29