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 (#26)
by
unknown
02:22
created

ClickatellClient::send()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 10
cp 0
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace NotificationChannels\Clickatell;
4
5
use stdClass;
6
use Clickatell\ClickatellException;
7
use Clickatell\Rest;
8
use NotificationChannels\Clickatell\Exceptions\CouldNotSendNotification;
9
10
class ClickatellClient
11
{
12
    const SUCCESSFUL_SEND = 0;
13
    const AUTH_FAILED = 1;
14
    const INVALID_DEST_ADDRESS = 105;
15
    const INVALID_API_ID = 108;
16
    const CANNOT_ROUTE_MESSAGE = 114;
17
    const DEST_MOBILE_BLOCKED = 121;
18
    const DEST_MOBILE_OPTED_OUT = 122;
19
    const MAX_MT_EXCEEDED = 130;
20
    const NO_CREDIT_LEFT = 301;
21
    const INTERNAL_ERROR = 901;
22
23
    /**
24
     * @var Rest
25
     */
26
    private $clickatell;
27
28
    /**
29
     * @param Rest $clickatellRest
30
     */
31
    public function __construct(Rest $clickatellRest)
32
    {
33
        $this->clickatell = $clickatellRest;
34
    }
35
36
    /**
37
     * @param array $to String or Array of numbers
38
     * @param string $message
39
     */
40
    public function send(array $to, $message)
41
    {
42
        $to = collect($to)->toArray();
43
44
        $client = new \GuzzleHttp\Client(['base_uri' => 'https://platform.clickatell.com/messages/http/']);
45
        $query = sprintf(
46
            'send?apiKey=%s&to=%s&content=%s',
47
            config('services.clickatell.api_key'),
48
            reset($to),
49
            $message
50
        );
51
        $response = $client->request('GET', $query);
0 ignored issues
show
Unused Code introduced by
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
52
    }
53
54
    /**
55
     * @return array
56
     */
57
    public function getFailedQueueCodes()
58
    {
59
        return [
60
            self::AUTH_FAILED,
61
            self::INVALID_DEST_ADDRESS,
62
            self::INVALID_API_ID,
63
            self::CANNOT_ROUTE_MESSAGE,
64
            self::DEST_MOBILE_BLOCKED,
65
            self::DEST_MOBILE_OPTED_OUT,
66
            self::MAX_MT_EXCEEDED,
67
        ];
68
    }
69
70
    /**
71
     * @return array
72
     */
73
    public function getRetryQueueCodes()
74
    {
75
        return [
76
            self::NO_CREDIT_LEFT,
77
            self::INTERNAL_ERROR,
78
        ];
79
    }
80
}
81