Completed
Pull Request — master (#6)
by
unknown
09:55
created

AwsPinpointSmsMessage::setSenderId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace NotificationChannels\AwsPinpoint;
4
5
class AwsPinpointSmsMessage
6
{
7
    public $body;
8
    public $messageType = 'TRANSACTIONAL';
9
    public $recipients;
10
    public $senderId;
11
12 8
    public function __construct($body = '')
13
    {
14 8
        if (! empty($body)) {
15 2
            $this->body = trim($body);
16
        }
17 8
    }
18
19 1
    public static function create($body = '')
20
    {
21 1
        return new static($body);
22
    }
23
24 1
    public function setBody($body)
25
    {
26 1
        $this->body = trim($body);
27
28 1
        return $this;
29
    }
30
31 1
    public function setMessageType($type)
32
    {
33 1
        $this->messageType = $type;
34
35 1
        return $this;
36
    }
37
38
    public function setSenderId($senderId)
39
    {
40
        $this->senderId = trim($senderId);
41
42
        return $this;
43
    }
44
45 3
    public function setRecipients($recipients)
46
    {
47 3
        if (is_string($recipients) === true || is_int($recipients) === true) {
48 2
            $recipients = [$recipients];
49
        }
50
51 3
        $output = [];
52
53 3
        foreach ($recipients as $number) {
54 3
            $output[$number] = [
55
                'ChannelType' => 'SMS',
56
            ];
57
        }
58
59 3
        $this->recipients = $output;
60
61 3
        return $this;
62
    }
63
}
64