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 ( e9f2be...fa9df5 )
by Peter
14:16 queued 14:14
created

MessagebirdClient::send()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 23
ccs 0
cts 22
cp 0
rs 8.5906
cc 5
eloc 14
nc 16
nop 1
crap 30
1
<?php
2
3
namespace NotificationChannels\Messagebird;
4
5
use Exception;
6
use GuzzleHttp\Client;
7
use NotificationChannels\Messagebird\Exceptions\CouldNotSendNotification;
8
9
class MessagebirdClient
10
{
11
    protected $client;
12
    protected $access_key;
13
14
    /**
15
     * MessagebirdClient constructor.
16
     * @param Client $client
17
     * @param $access_key string API Key from Messagebird API
18
     */
19
    public function __construct(Client $client, $access_key)
20
    {
21
        $this->client = $client;
22
        $this->access_key = $access_key;
23
    }
24
25
    /**
26
     * Send the Message.
27
     * @param MessagebirdMessage $message
28
     * @throws CouldNotSendNotification
29
     */
30
    public function send(MessagebirdMessage $message)
31
    {
32
        if (empty($message->originator)) {
33
            $message->setOriginator(config('services.messagebird.originator'));
34
        }
35
        if (empty($message->recipients)) {
36
            $message->setRecipients(config('services.messagebird.recipients'));
37
        }
38
        if (empty($message->datacoding)) {
0 ignored issues
show
Bug introduced by
The property datacoding does not seem to exist in NotificationChannels\Mes...bird\MessagebirdMessage.

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...
39
            $message->setDatacoding('auto');
40
        }
41
42
        try {
43
            $this->client->request('POST', 'https://rest.messagebird.com/messages', [
44
                'body' => $message->toJson(),
45
                'headers' => [
46
                    'Authorization' => 'AccessKey '.$this->access_key,
47
                ],
48
            ]);
49
        } catch (Exception $exception) {
50
            throw CouldNotSendNotification::serviceRespondedWithAnError($exception);
51
        }
52
    }
53
}
54