SmsHandler::sendSingleSms()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3.0327

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 11
c 1
b 0
f 0
nc 1
nop 5
dl 0
loc 21
ccs 11
cts 13
cp 0.8462
crap 3.0327
rs 9.9
1
<?php
2
/**
3
 * File: SmsHandler.php
4
 *
5
 * @author      Maciej Sławik <[email protected]>
6
 * Github:      https://github.com/maciejslawik
7
 */
8
9
namespace MSlwk\FreshMail\Handler\Message;
10
11
use MSlwk\FreshMail\Handler\AbstractHandler;
12
13
/**
14
 * Class SmsHandler
15
 *
16
 * @package MSlwk\FreshMail\Handler\Message
17
 */
18
class SmsHandler extends AbstractHandler
19
{
20
    const API_ENDPOINT = '/rest/sms/send';
21
22
    /**
23
     * @param string $phoneNumber
24
     * @param string $content
25
     * @param string $from
26
     * @param string $messageId
27
     * @param bool $single
28
     * @return null
29
     */
30 77
    public function sendSingleSms(
31
        string $phoneNumber,
32
        string $content,
33
        string $from = '',
34
        string $messageId = '',
35
        bool $single = false
36
    ) {
37 77
        $getParameters = [];
38 22
        $postParameters = [
39 77
            'gsm' => $phoneNumber,
40 77
            'text' => $content,
41
            'from' => $from ?: null,
42 77
            'single' => $single,
43
            'messageId' => $messageId ?: null
44
        ];
45
46 55
        $postParameters = array_filter($postParameters, function ($value) {
47 77
            return $value !== null;
48 77
        });
49 77
        $this->processRequest($getParameters, $postParameters);
50 7
        return null;
51
    }
52
53
    /**
54
     * @return string
55
     */
56 7
    protected function getApiEndpoint(): string
57
    {
58 7
        return self::API_ENDPOINT;
59
    }
60
}
61