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 (#15)
by
unknown
06:50
created

TwitterChannel::send()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 13.6948

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 2
cts 13
cp 0.1538
rs 9.2
c 0
b 0
f 0
cc 4
eloc 10
nc 4
nop 2
crap 13.6948
1
<?php
2
3
namespace NotificationChannels\Twitter;
4
5
use Abraham\TwitterOAuth\TwitterOAuth;
6
use Illuminate\Notifications\Notification;
7
use NotificationChannels\Twitter\Exceptions\CouldNotSendNotification;
8
9
class TwitterChannel
10
{
11
    /** @var TwitterOAuth */
12
    protected $twitter;
13
14
    /**
15
     * @param TwitterOAuth $twitter
16
     */
17 3
    public function __construct(TwitterOAuth $twitter)
18
    {
19 3
        $this->twitter = $twitter;
20 3
    }
21
22
    /**
23
     * Send the given notification.
24
     *
25
     * @param mixed                                  $notifiable
26
     * @param \Illuminate\Notifications\Notification $notification
27
     *
28
     * @throws CouldNotSendNotification
29
     */
30 3
    public function send($notifiable, Notification $notification)
31
    {
32 3
        $twitterMessage = $notification->toTwitter($notifiable);
0 ignored issues
show
Bug introduced by
The method toTwitter() 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...
33
        if (is_a($twitterMessage, TwitterStatusUpdate::class) && $twitterMessage->getImagePaths()) {
34
            $this->twitter->setTimeouts(10, 15);
35
36
            $twitterMessage->imageIds = $twitterMessage->getImagePaths()->map(function ($path) {
37
                $media = $this->twitter->upload('media/upload', ['media' => $path]);
38
39
                return $media->media_id_string;
40
            });
41
        }
42
43
        $this->twitter->post($twitterMessage->getApiEndpoint(), $twitterMessage->getRequestBody());
44
45
        if ($this->twitter->getLastHttpCode() !== 200) {
46
            throw CouldNotSendNotification::serviceRespondedWithAnError($this->twitter->getLastBody());
47
        }
48
    }
49
}
50