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.

FacebookPosterChannel::send()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 8
c 4
b 0
f 0
dl 0
loc 16
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace NotificationChannels\FacebookPoster;
4
5
use GuzzleHttp\Client;
6
use Illuminate\Contracts\Config\Repository;
7
use Illuminate\Notifications\Notification;
8
use Illuminate\Support\Arr;
9
10
class FacebookPosterChannel
11
{
12
    /**
13
     * The Guzzle client.
14
     */
15
    protected Client $guzzle;
16
17
    /**
18
     * The application config.
19
     */
20
    protected Repository $config;
21
22 4
    /**
23
     * Create a new channel instance.
24 4
     */
25 4
    public function __construct(Client $guzzle, Repository $config)
26
    {
27
        $this->guzzle = $guzzle;
28
        $this->config = $config;
29
    }
30
31
    /**
32
     * Send the given notification.
33 4
     *
34
     * @param  mixed  $notifiable
35 4
     * @param  \Illuminate\Notifications\Notification  $notification
36
     */
37
    public function send($notifiable, Notification $notification)
38
    {
39 4
        $post = $notification->toFacebookPoster($notifiable);
0 ignored issues
show
introduced by
The method toFacebookPoster() does not exist on Illuminate\Notifications\Notification. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        /** @scrutinizer ignore-call */ 
40
        $post = $notification->toFacebookPoster($notifiable);
Loading history...
40
41 4
        $routing = $notifiable->routeNotificationFor('facebookPoster');
42
43 4
        $pageId = Arr::get($routing, 'page_id', function () {
44 2
            return $this->config->get('services.facebook_poster.page_id');
45
        });
46
47 4
        $accessToken = Arr::get($routing, 'access_token', function () {
48 4
            return $this->config->get('services.facebook_poster.access_token');
49
        });
50
51
        $this->guzzle->post("https://graph.facebook.com/v18.0/{$pageId}/feed?access_token={$accessToken}", [
52
            'form_params' => $post->getBody(),
53
        ]);
54
    }
55
}
56