Completed
Push — master ( 395778...35ff7e )
by Dwight
8s
created

ApnAdapter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 27
ccs 0
cts 13
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A adapt() 0 17 1
1
<?php
2
3
namespace NotificationChannels\Apn;
4
5
use ZendService\Apple\Apns\Message;
6
use ZendService\Apple\Apns\Message\Alert;
7
8
class ApnAdapter
9
{
10
    /**
11
     * Convert an ApnMessage instance into a Zend Apns Message.
12
     *
13
     * @param  \NotificationChannels\Apn\ApnMessage  $message
14
     * @param  string  $token
15
     * @return \ZendService\Apple\Apns\Message
16
     */
17
    public function adapt(ApnMessage $message, $token)
18
    {
19
        $alert = new Alert();
20
        $alert->setTitle($message->title);
21
        $alert->setBody($message->body);
22
23
        $packet = new Message;
24
        $packet->setToken($token);
25
        $packet->setBadge($message->badge);
26
        $packet->setSound($message->sound);
27
        $packet->setCategory($message->category);
28
        $packet->setContentAvailable($message->contentAvailable);
29
        $packet->setAlert($alert);
30
        $packet->setCustom($message->custom);
31
32
        return $packet;
33
    }
34
}
35