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

ApnChannel::sendNotifications()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
namespace NotificationChannels\Apn;
4
5
use Illuminate\Notifications\Notification;
6
use Pushok\Client;
7
8
class ApnChannel
9
{
10
    /**
11
     * The sandbox environment identifier.
12
     *
13
     * @var int
14
     */
15
    const SANDBOX = 0;
16
17
    /**
18
     * The production environment identifier.
19
     *
20
     * @var int
21
     */
22
    const PRODUCTION = 1;
23
24
    /**
25
     * The APNS client.
26
     *
27
     * @var \Pushok\Client
28
     */
29
    protected $client;
30
31
    /**
32
     * Create a new channel instance.
33
     *
34
     * @param  \Pushok\Client  $client
35
     */
36 1
    public function __construct(Client $client)
37
    {
38 1
        $this->client = $client;
39 1
    }
40
41
    /**
42
     * Send the notification to Apple Push Notification Service.
43
     *
44
     * @param mixed $notifiable
45
     * @param \Illuminate\Notifications\Notification $notification
46
     * @return array|void
47
     */
48 1
    public function send($notifiable, Notification $notification)
49
    {
50 1
        $tokens = (array) $notifiable->routeNotificationFor('apn', $notification);
51
52 1
        if (empty($tokens)) {
53
            return;
54
        }
55
56 1
        $message = $notification->toApn($notifiable);
0 ignored issues
show
Bug introduced by
The method toApn() does not seem to exist on object<Illuminate\Notifications\Notification>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
58 1
        $client = $message->client ?? $this->client;
59
60 1
        foreach ($tokens as $token) {
61 1
            $client->addNotification((new ApnAdapter)->adapt($message, $token));
62
        }
63
64 1
        return $client->push();
65
    }
66
}
67