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 (#3)
by
unknown
63:19
created

ClickatellHandler   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 58
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A buildContent() 0 15 4
A buildRequestUrl() 0 4 1
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 string $limit      The character limit
29
     */
30
    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
        if($version !== self::API_V1){
33
            throw new Exception('API Version \'{$version}\' is not supported!');
34
        }
35
        parent::__construct($secret, null, $fromNumber, $toNumber, $level, $bubble, $useSSL, $host, $version, $limit);
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     *
41
     * @param  array  $record
42
     * @return string
43
     */
44
    protected function buildContent($record)
45
    {
46
        if(strlen($record['formatted']) > $this->limit){
47
            $record['formatted'] = substr($record['formatted'], 0, $this->limit);
0 ignored issues
show
Bug introduced by
The property limit does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
48
        }
49
50
        $dataArray = [
51
            'content' => $record['formatted'],
52
            'to' => (!is_array($this->toNumber)? [$this->toNumber] : $this->toNumber)
53
        ];
54
55
        ($this->fromNumber)? $dataArray["from"] = $this->fromNumber : false;
56
        
57
        return json_encode($dataArray);
58
    }
59
60
    /**
61
     * Builds the URL for the API call
62
     * 
63
     * @return string
64
     */
65
    protected function buildRequestUrl()
66
    {
67
        return "POST /messages HTTP/1.1\r\n";
68
    }
69
}
70