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 (#10)
by Marcel
12:59 queued 10:18
created

TwitterChannel::send()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3.512

Importance

Changes 5
Bugs 1 Features 0
Metric Value
c 5
b 1
f 0
dl 0
loc 17
ccs 8
cts 13
cp 0.6153
rs 9.4285
cc 3
eloc 11
nc 4
nop 2
crap 3.512
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 2
    public function __construct(TwitterOAuth $twitter)
18
    {
19 2
        $this->twitter = $twitter;
20 2
    }
21
22
    /**
23
     * Send the given notification.
24
     *
25
     * @param mixed                                  $notifiable
26
     * @param \Illuminate\Notifications\Notification $notification
27
     *
28
     * @throws CouldNotSendNotification
29
     */
30 2
    public function send($notifiable, Notification $notification)
31
    {
32 2
        $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 2
        if ($twitterMessage->getReceiver() != null) {
34
            $response = $this->twitter->post('direct_messages/new', [
35
                    'text' => $twitterMessage->getContent(),
36
                    'screen_name' => $twitterMessage->getReceiver(),
37
                ]);
38
        } else {
39 2
            $response = $this->twitter->post(
40 2
                'statuses/update', ['status' => $twitterMessage->getContent()]);
41
        }
42
43 2
        if ($response->getHttpCode() !== 200) {
44 1
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
45
        }
46 1
    }
47
}
48