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 ( 554576...c39576 )
by Irfaq
02:20
created

FacebookChannel::send()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

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