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