GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 466e5a...bfa63f )
by Dwight
03:16
created

ApnAdapter::adapt()   C

Complexity

Conditions 9
Paths 256

Size

Total Lines 45

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 24
CRAP Score 9

Importance

Changes 0
Metric Value
dl 0
loc 45
ccs 24
cts 24
cp 1
rs 6.4177
c 0
b 0
f 0
cc 9
nc 256
nop 2
crap 9
1
<?php
2
3
namespace NotificationChannels\Apn;
4
5
use Pushok\Notification;
6
use Pushok\Payload;
7
use Pushok\Payload\Alert;
8
9
class ApnAdapter
10
{
11
    /**
12
     * Convert an ApnMessage instance into a Zend Apns Message.
13
     *
14
     * @param  \NotificationChannels\Apn\ApnMessage  $message
15
     * @param  string  $token
16
     * @return \Pushok\Notification
17
     */
18 16
    public function adapt(ApnMessage $message, string $token)
19
    {
20 16
        $alert = Alert::create();
21
22 16
        if ($title = $message->title) {
23 4
            $alert->setTitle($title);
24
        }
25
26 16
        if ($body = $message->body) {
27 1
            $alert->setBody($body);
28
        }
29
30 16
        $payload = Payload::create()
31 16
            ->setAlert($alert)
32 16
            ->setContentAvailability((bool) $message->contentAvailable)
33 16
            ->setMutableContent((bool) $message->mutableContent);
34
35 16
        if ($badge = $message->badge) {
36 1
            $payload->setBadge($badge);
37
        }
38
39 16
        if ($sound = $message->sound) {
40 1
            $payload->setSound($sound);
41
        }
42
43 16
        if ($category = $message->category) {
44 1
            $payload->setCategory($category);
45
        }
46
47 16
        foreach ($message->custom as $key => $value) {
48 1
            $payload->setCustomValue($key, $value);
49
        }
50
51 16
        if ($pushType = $message->pushType) {
52 4
            $payload->setPushType($pushType);
53
        }
54
55 16
        $notification = new Notification($payload, $token);
56
57 16
        if ($expiresAt = $message->expiresAt) {
58 1
            $notification->setExpirationAt($expiresAt);
59
        }
60
61 16
        return $notification;
62
    }
63
}
64