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
Pull Request — master (#31)
by
unknown
01:59 queued 15s
created

FacebookChannel::send()   B

Complexity

Conditions 5
Paths 10

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 0
cts 17
cp 0
rs 8.6737
c 0
b 0
f 0
cc 5
eloc 11
nc 10
nop 2
crap 30
1
<?php
2
3
namespace NotificationChannels\Facebook;
4
5
use Illuminate\Container\Container;
6
use Illuminate\Notifications\Notification;
7
use NotificationChannels\Facebook\Exceptions\CouldNotCreateMessage;
8
9
class FacebookChannel
10
{
11
    /** @var Facebook */
12
    private $fb;
13
14
    /**
15
     * FacebookChannel constructor.
16
     *
17
     * @param Facebook $fb
18
     */
19
    public function __construct(Facebook $fb)
20
    {
21
        $this->fb = $fb;
22
    }
23
24
    /**
25
     * Send the given notification.
26
     *
27
     * @param mixed                                  $notifiable
28
     * @param \Illuminate\Notifications\Notification $notification
29
     *
30
     * @throws \NotificationChannels\Facebook\Exceptions\CouldNotCreateMessage
31
     */
32
    public function send($notifiable, Notification $notification)
33
    {
34
        $message = $notification->toFacebook($notifiable);
0 ignored issues
show
Bug introduced by
The method toFacebook() 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...
35
36
        if (is_string($message)) {
37
            $message = FacebookMessage::create($message);
38
        }
39
40
        if ($message->toNotGiven()) {
41
            if (! $to = $notifiable->routeNotificationFor('facebook')) {
42
                throw CouldNotCreateMessage::recipientNotProvided();
43
            }
44
45
            $message->to($to);
46
        }
47
48
        if ($message->senderGiven()) {
49
            $this->fb = Container::getInstance()->make(Facebook::class, ['token' => $message->sender]);
50
        }
51
52
        $this->fb->send($message->toArray());
53
    }
54
}
55