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 ( 4eaeb4...a5c5f4 )
by Mohamed
02:00
created

FacebookChannel::send()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 18
rs 9.2
cc 4
eloc 9
nc 6
nop 2
1
<?php
2
3
namespace NotificationChannels\Facebook;
4
5
use Illuminate\Notifications\Notification;
6
use NotificationChannels\Facebook\Exceptions\CouldNotSendNotification;
7
8
class FacebookChannel
9
{
10
    /**
11
     * @var Facebook
12
     */
13
    private $fb;
14
15
    public function __construct(Facebook $fb)
16
    {
17
        $this->fb = $fb;
18
    }
19
20
    /**
21
     * Send the given notification.
22
     *
23
     * @param mixed                                  $notifiable
24
     * @param \Illuminate\Notifications\Notification $notification
25
     *
26
     * @throws \NotificationChannels\Facebook\Exceptions\CouldNotSendNotification
27
     */
28
    public function send($notifiable, Notification $notification)
29
    {
30
        $message = $notification->toFacebook($notifiable);
31
32
        if (is_string($message)) {
33
            $message = FacebookMessage::create($message);
34
        }
35
36
        if ($message->toNotGiven()) {
37
            if (! $to = $notifiable->routeNotificationFor('facebook')) {
38
                throw CouldNotSendNotification::recipientNotProvided();
39
            }
40
41
            $message->to($to);
42
        }
43
44
        $this->fb->send($message->toArray());
45
    }
46
}
47