AwsPinpointSmsMessage::setRecipients()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 9.6666
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4
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 3
    public function setRecipients($recipients)
39
    {
40 3
        if (is_string($recipients) === true || is_int($recipients) === true) {
41 2
            $recipients = [$recipients];
42
        }
43
44 3
        $output = [];
45
46 3
        foreach ($recipients as $number) {
47 3
            $output[$number] = [
48
                'ChannelType' => 'SMS',
49
            ];
50
        }
51
52 3
        $this->recipients = $output;
53
54 3
        return $this;
55
    }
56
}
57