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.

FacebookChannel   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 5
dl 0
loc 48
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 20 4
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
     * @return array
35
     *
36
     * @throws CouldNotCreateMessage
37
     * @throws CouldNotSendNotification
38
     * @throws GuzzleException
39
     */
40
    public function send($notifiable, Notification $notification): array
41
    {
42
        $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...
43
44
        if (is_string($message)) {
45
            $message = FacebookMessage::create($message);
46
        }
47
48
        if ($message->toNotGiven()) {
49
            if (! $to = $notifiable->routeNotificationFor('facebook')) {
50
                throw CouldNotCreateMessage::recipientNotProvided();
51
            }
52
53
            $message->to($to);
54
        }
55
56
        $response = $this->fb->send($message->toArray());
57
58
        return json_decode($response->getBody()->getContents(), true);
59
    }
60
}
61