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 ( 5c1085...66d259 )
by Tyler
04:28 queued 33s
created

ClickatellHandler::buildContent()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.1755

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 7
cts 9
cp 0.7778
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 8
nop 1
crap 4.1755
1
<?php
2
3
namespace Tylercd100\Monolog\Handler;
4
5
use Exception;
6
use Monolog\Logger;
7
8
/**
9
* Clickatell - Monolog Handler
10
* @url https://www.clickatell.com/developers/api-documentation/rest-api-request-parameters
11
*/
12
class ClickatellHandler extends SMSHandler
13
{
14
    /**
15
     * API version 1
16
     */
17
    const API_V1 = '2010-04-01';
18
19
    /**
20
     * @param string $secret     Twilio API Secret Token
21
     * @param string $fromNumber The phone number that will be shown as the sender ID
22
     * @param string $toNumber   The phone number to which the message will be sent
23
     * @param int    $level      The minimum logging level at which this handler will be triggered
24
     * @param bool   $bubble     Whether the messages that are handled can bubble up the stack or not
25
     * @param bool   $useSSL     Whether to connect via SSL.
26
     * @param string $host       The Twilio server hostname.
27
     * @param string $version    The Twilio API version (default ClickatellHandler::API_V1)
28
     * @param int    $limit      The character limit
29
     */
30 18
    public function __construct($secret, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'platform.clickatell.com', $version = self::API_V1, $limit = 160)
31
    {
32 18
        if ($version !== self::API_V1) {
33 3
            throw new Exception("API Version \'{$version}\' is not supported!");
34
        }
35 15
        parent::__construct($secret, null, $fromNumber, $toNumber, $level, $bubble, $useSSL, $host, $version, $limit);
36 15
    }
37
38
    /**
39
     * {@inheritdoc}
40
     *
41
     * @param  array  $record
42
     * @return string
43
     */
44 12
    protected function buildContent($record)
45
    {
46 12
        if (strlen($record['formatted']) > $this->limit) {
47
            $record['formatted'] = substr($record['formatted'], 0, $this->limit);
48
        }
49
50
        $dataArray = [
51 12
            'content' => $record['formatted'],
52 12
            'to' => (!is_array($this->toNumber)? [$this->toNumber] : $this->toNumber)
53 12
        ];
54
55 12
        ($this->fromNumber)? $dataArray['from'] = $this->fromNumber : false;
56
57 12
        return json_encode($dataArray);
58
    }
59
60
    /**
61
     * Builds the URL for the API call
62
     *
63
     * @return string
64
     */
65 12
    protected function buildRequestUrl()
66
    {
67 12
        return "POST /messages HTTP/1.1\r\n";
68
    }
69
}
70