SmsHandler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 86.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 41
ccs 13
cts 15
cp 0.8667
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getApiEndpoint() 0 3 1
A sendSingleSms() 0 21 3
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