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 ( 4e1a26...3707bf )
by Dwight
02:57 queued 43s
created

ApnAdapter   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 72.72%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 4
dl 0
loc 51
ccs 16
cts 22
cp 0.7272
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B adapt() 0 41 8
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 1
    public function adapt(ApnMessage $message, string $token)
19
    {
20 1
        $alert = Alert::create();
21
22 1
        if ($title = $message->title) {
23 1
            $alert->setTitle($title);
24
        }
25
26 1
        if ($body = $message->body) {
27
            $alert->setBody($body);
28
        }
29
30 1
        $payload = Payload::create()
31 1
            ->setAlert($alert)
32 1
            ->setContentAvailability((bool) $message->contentAvailable)
33 1
            ->setMutableContent((bool) $message->mutableContent);
34
35 1
        if ($badge = $message->badge) {
36
            $payload->setBadge($badge);
37
        }
38
39 1
        if ($sound = $message->sound) {
40
            $payload->setSound($sound);
41
        }
42
43 1
        if ($category = $message->category) {
44
            $payload->setCategory($category);
45
        }
46
47 1
        foreach ($message->custom as $key => $value) {
48
            $payload->setCustomValue($key, $value);
49
        }
50
51 1
        $notification = new Notification($payload, $token);
52
53 1
        if ($expiresAt = $message->expiresAt) {
54
            $notification->setExpirationAt($expiresAt);
55
        }
56
57 1
        return $notification;
58
    }
59
}
60