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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 71
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFailedQueueCodes() 0 12 1
A getRetryQueueCodes() 0 7 1
A send() 0 13 1
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