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 ( 8dd544...a309ea )
by Dwight
02:58
created

FacebookPosterChannel::send()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3.0032

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 13
cts 14
cp 0.9286
rs 9.504
c 0
b 0
f 0
cc 3
nc 4
nop 2
crap 3.0032
1
<?php
2
3
namespace NotificationChannels\FacebookPoster;
4
5
use Facebook\Facebook;
6
use Illuminate\Notifications\Notification;
7
use NotificationChannels\FacebookPoster\Exceptions\InvalidPostContent;
8
9
class FacebookPosterChannel
10
{
11
    /** @var \Facebook\Facebook */
12
    protected $facebook;
13
14
    /**
15
     * @param \Facebook\Facebook $facebook
16
     */
17 4
    public function __construct(Facebook $facebook)
18
    {
19 4
        $this->facebook = $facebook;
20 4
    }
21
22
    /**
23
     * Send the given notification.
24
     *
25
     * @param mixed                                  $notifiable
26
     * @param \Illuminate\Notifications\Notification $notification
27
     *
28
     * @throws InvalidPostContentException
29
     */
30 4
    public function send($notifiable, Notification $notification)
31
    {
32 4
        if ($facebookSettings = $notifiable->routeNotificationFor('facebookPoster')) {
33
            $this->switchSettings($facebookSettings);
34
        }
35
36 4
        $facebookMessage = $notification->toFacebookPoster($notifiable);
0 ignored issues
show
Bug introduced by
The method toFacebookPoster() 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...
37
38 4
        $postBody = $facebookMessage->getPostBody();
39
40 4
        $endpoint = $facebookMessage->getApiEndpoint();
41
42 4
        if (isset($postBody['media'])) {
43 2
            $endpoint = $postBody['media']->getApiEndpoint();
44
45 2
            $postBody = array_merge($postBody, $postBody['media']->getData());
46
47 2
            $method = $postBody['media']->getApiMethod();
48
49 2
            $postBody['source'] = $this->facebook->{$method}($postBody['media']->getPath());
50
51 2
            unset($postBody['media']);
52
        }
53
54 4
        $this->facebook->post($endpoint, $postBody);
55 4
    }
56
57
    /**
58
     * Use per user settings instead of default ones.
59
     * @param $facebookSettings
60
     */
61
    private function switchSettings($facebookSettings)
62
    {
63
        $this->facebook = new Facebook($facebookSettings);
64
    }
65
}
66