Conditions | 7 |
Paths | 64 |
Total Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 7.8934 |
Changes | 0 |
1 | <?php |
||
16 | 1 | public function adapt(ApnMessage $message) |
|
17 | { |
||
18 | 1 | $alert = Alert::create(); |
|
19 | |||
20 | 1 | if ($title = $message->title) { |
|
21 | 1 | $alert->setTitle($title); |
|
22 | } |
||
23 | |||
24 | 1 | if ($body = $message->body) { |
|
25 | $alert->setBody($body); |
||
26 | } |
||
27 | |||
28 | 1 | $payload = Payload::create() |
|
29 | 1 | ->setAlert($alert) |
|
30 | 1 | ->setContentAvailability((bool) $message->contentAvailable) |
|
31 | 1 | ->setMutableContent((bool) $message->mutableContent); |
|
32 | |||
33 | 1 | if ($badge = $message->badge) { |
|
34 | $payload->setBadge($badge); |
||
35 | } |
||
36 | |||
37 | 1 | if ($sound = $message->sound) { |
|
38 | $payload->setSound($sound); |
||
39 | } |
||
40 | |||
41 | 1 | if ($category = $message->category) { |
|
42 | $payload->setCategory($category); |
||
43 | } |
||
44 | |||
45 | 1 | foreach ($message->custom as $key => $value) { |
|
46 | $payload->setCustomValue($key, $value); |
||
47 | } |
||
48 | |||
49 | 1 | return $payload; |
|
50 | } |
||
51 | } |
||
52 |