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 (#27)
by
unknown
02:32 queued 15s
created

MessagebirdChannel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace NotificationChannels\Messagebird;
4
5
use Illuminate\Contracts\Events\Dispatcher;
6
use Illuminate\Notifications\Events\NotificationFailed;
7
use Illuminate\Notifications\Notification;
8
use NotificationChannels\Messagebird\Exceptions\CouldNotSendNotification;
9
10
class MessagebirdChannel
11
{
12
    /** @var \NotificationChannels\Messagebird\MessagebirdClient */
13
    protected $client;
14
    private $_dispatcher;
15
16 3
    public function __construct(MessagebirdClient $client, Dispatcher $dispatcher = null)
17
    {
18 3
        $this->client = $client;
19 3
        $this->dispatcher = $dispatcher;
0 ignored issues
show
Bug introduced by
The property dispatcher does not seem to exist. Did you mean _dispatcher?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
20 3
    }
21
22
    /**
23
     * Send the given notification.
24
     *
25
     * @param mixed $notifiable
26
     * @param \Illuminate\Notifications\Notification $notification
27
     *
28
     * @return array
29
     * @throws \NotificationChannels\MessageBird\Exceptions\CouldNotSendNotification
30
     */
31 2
    public function send($notifiable, Notification $notification)
32
    {
33 2
        $message = $notification->toMessagebird($notifiable);
0 ignored issues
show
Bug introduced by
The method toMessagebird() 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...
34
35 2
        $response = [];
36
37 2
        if (is_string($message)) {
38 1
            $message = MessagebirdMessage::create($message);
39
        }
40
41 2
        if ($to = $notifiable->routeNotificationFor('messagebird')) {
42 2
            $message->setRecipients($to);
43
        }
44
45
        try {
46 2
            $response = $this->client->send($message);
47
48 2
            if($this->dispatcher !== null) {
0 ignored issues
show
Bug introduced by
The property dispatcher does not seem to exist. Did you mean _dispatcher?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
49 2
                $this->dispatcher->dispatch('messagebird-sms', [$notifiable, $notification, $response]);
0 ignored issues
show
Bug introduced by
The property dispatcher does not seem to exist. Did you mean _dispatcher?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
50
            }
51
        } catch (CouldNotSendNotification $e) {
52
            new NotificationFailed(
53
                $notifiable,
54
                $notification,
55
                'messagebird-sms',
56
                $e->getMessage()
0 ignored issues
show
Documentation introduced by
$e->getMessage() is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
57
            );
58
        }
59
60 2
        return $response;
61
    }
62
}
63