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 ( be1536...cdf555 )
by Peter
02:55
created

MessagebirdClient::send()   B

Complexity

Conditions 6
Paths 16

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 18
rs 8.8571
cc 6
eloc 13
nc 16
nop 1
1
<?php
2
3
namespace NotificationChannels\Messagebird;
4
5
use Exception;
6
use MessageBird\Exceptions\AuthenticateException;
7
use MessageBird\Exceptions\BalanceException;
8
use NotificationChannels\Messagebird\Exceptions\CouldNotSendNotification;
9
use MessageBird\Client;
10
11
class MessagebirdClient
12
{
13
    protected $client;
14
15
    public function __construct(Client $client)
16
    {
17
        $this->client = $client;
18
    }
19
20
    public function send($message) {
21
        if (empty($message->originator)) {
22
            $message->setOriginator(config('services.messagebird.originator'));
23
        }
24
        if (empty($message->recipients)) {
25
            $message->setRecipients(config('services.messagebird.recipients'));
26
        }
27
28
        try {
29
            $this->client->messages->create($message);
30
        } catch (AuthenticateException $exception) {
31
            throw CouldNotSendNotification::couldNotAuthenticate();
32
        } catch (BalanceException $exception) {
33
            throw CouldNotSendNotification::notEnoughCredits();
34
        } catch (Exception $exception) {
35
            throw CouldNotSendNotification::serviceRespondedWithAnError($exception);
36
        }
37
    }
38
}
39