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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 46
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B send() 0 22 5
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