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

AwsPinpointSmsMessage   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 86.96%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 0
dl 0
loc 59
ccs 20
cts 23
cp 0.8696
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A create() 0 4 1
A setBody() 0 6 1
A setMessageType() 0 6 1
A setSenderId() 0 6 1
A setRecipients() 0 18 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
    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