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.

Sender::send()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
dl 0
loc 42
rs 8.8571
c 5
b 0
f 0
cc 1
eloc 25
nc 1
nop 2
1
<?php
2
3
/**
4
 * This file is a part of the Yoqut package.
5
 *
6
 * (c) Sukhrob Khakimov <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that is distributed with this source code.
10
 */
11
12
namespace Yoqut\Component\Sms\Sender;
13
14
use Yoqut\Component\Sms\Model\SmsInterface;
15
use Yoqut\Component\Sms\Model\GatewayInterface;
16
17
/**
18
 * The default sender implementation
19
 *
20
 * @author Sukhrob Khakimov <[email protected]>
21
 */
22
class Sender implements SenderInterface
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27
    public function send(SmsInterface $sms, GatewayInterface $gateway)
28
    {
29
        // Get the gateway configurations
30
        $configs = $gateway->getConfigs();
31
32
        // Create a new socket transport
33
        $transport = new \SocketTransport(
34
            array($gateway->getHost()),
35
            $gateway->getPort(),
36
            $configs['persistent']
37
        );
38
        $transport->setSendTimeout($configs['send_timeout']);
39
        $transport->setRecvTimeout($configs['receive_timeout']);
40
        $transport->debug = $configs['debug'];
41
42
        // Create a new SMPP client
43
        $smpp = new \SmppClient($transport);
44
        $smpp->debug = $configs['debug'];
45
46
        // Open the connection
47
        $transport->open();
48
        $smpp->bindTransmitter($gateway->getUsername(), $gateway->getPassword());
49
50
        // Configure a sender, recipient and message
51
        $sender = new \SmppAddress(
52
            $sms->getSender(),
53
            $configs['sender']['ton'],
54
            $configs['sender']['npi']
55
        );
56
        $recipient = new \SmppAddress(
57
            $sms->getRecipient(),
58
            $configs['recipient']['ton'],
59
            $configs['recipient']['npi']
60
        );
61
        $message = \GsmEncoder::utf8_to_gsm0338($sms->getMessage());
62
63
        // Send an SMS and close the connection
64
        $messageId = $smpp->sendSMS($sender, $recipient, $message);
65
        $smpp->close();
66
67
        return $messageId;
68
    }
69
}
70