Completed
Push — master ( 85222f...c3043f )
by Massimiliano
03:15
created

Sms::setText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Fazland\SkebbyRestClient\DataStructure;
4
5
/**
6
 * @author Massimiliano Braglia <[email protected]>
7
 */
8
class Sms
9
{
10
    /**
11
     * @var string[]
12
     */
13
    private $recipients;
14
15
    /**
16
     * @var string[][]
17
     */
18
    private $recipientVariables;
19
20
    /**
21
     * @var string
22
     */
23
    private $text;
24
25
    /**
26
     * @var string
27
     */
28
    private $userReference;
29
30
    /**
31
     * Sms constructor.
32
     */
33 5
    public function __construct()
34
    {
35 5
        $this->recipients = [];
36 5
        $this->recipientVariables = [];
37 5
    }
38
39
    /**
40
     * @return static
41
     */
42 5
    public static function create()
43
    {
44 5
        return new static();
45
    }
46
47
    /**
48
     * @return string[]
49
     */
50 5
    public function getRecipients()
51
    {
52 5
        return $this->recipients;
53
    }
54
55
    /**
56
     * @param string[] $recipients
57
     *
58
     * @return $this
59
     */
60 4
    public function setRecipients(array $recipients)
61
    {
62 4
        $this->recipients = $recipients;
63
64 4
        return $this;
65
    }
66
67
    /**
68
     * @param string $recipient
69
     *
70
     * @return $this
71
     */
72
    public function addRecipient($recipient)
73
    {
74
        $this->recipients[] = $recipient;
75
76
        return $this;
77
    }
78
79
    /**
80
     * @param string $recipient
81
     *
82
     * @return $this
83
     */
84
    public function removeTo($recipient)
85
    {
86
        $itemPosition = array_search($recipient, $this->recipients);
87
88
        if (false !== $itemPosition) {
89
            unset($this->recipients[$itemPosition]);
90
        }
91
92
        return $this;
93
    }
94
95
    /**
96
     * @return bool
97
     */
98 5
    public function hasRecipients()
99
    {
100 5
        return ! empty($this->recipients);
101
    }
102
103
    /**
104
     * @return string[][]
105
     */
106 4
    public function getRecipientVariables()
107
    {
108 4
        return $this->recipientVariables;
109
    }
110
111
    /**
112
     * @param string $recipient
113
     * @param string[] $recipientVariables
114
     *
115
     * @return $this
116
     */
117 1
    public function setRecipientVariables($recipient, array $recipientVariables)
118
    {
119 1
        $this->recipientVariables[$recipient] = $recipientVariables;
120
121 1
        return $this;
122
    }
123
124
    /**
125
     * @param string $recipient
126
     * @param string $recipientVariable
127
     * @param string $recipientVariableValue
128
     *
129
     * @return $this
130
     */
131
    public function addRecipientVariable($recipient, $recipientVariable, $recipientVariableValue)
132
    {
133
        if (! isset($this->recipientVariables[$recipient])) {
134
            $this->recipientVariables[$recipient] = [];
135
        }
136
137
        $this->recipientVariables[$recipient][$recipientVariable] = $recipientVariableValue;
138
139
        return $this;
140
    }
141
142
    /**
143
     * @param string $recipient
144
     * @param string $recipientVariable
145
     *
146
     * @return $this
147
     */
148
    public function removeRecipientVariable($recipient, $recipientVariable)
149
    {
150
        unset($this->recipientVariables[$recipient][$recipientVariable]);
151
152
        return $this;
153
    }
154
155
    /**
156
     * @return bool
157
     */
158
    public function hasRecipientVariables()
159
    {
160
        return ! empty($this->recipientVariables);
161
    }
162
163
    /**
164
     * @return $this
165
     */
166
    public function clearRecipientVariables()
167
    {
168
        $this->recipientVariables = [];
169
170
        return $this;
171
    }
172
173
    /**
174
     * @return string
175
     */
176 4
    public function getText()
177
    {
178 4
        return $this->text;
179
    }
180
181
    /**
182
     * @param string $text
183
     *
184
     * @return $this
185
     */
186 5
    public function setText($text)
187
    {
188 5
        $this->text = $text;
189
190 5
        return $this;
191
    }
192
193
    /**
194
     * @return string
195
     */
196 4
    public function getUserReference()
197
    {
198 4
        return $this->userReference;
199
    }
200
201
    /**
202
     * @param string $userReference
203
     *
204
     * @return $this
205
     */
206
    public function setUserReference($userReference)
207
    {
208
        $this->userReference = $userReference;
209
210
        return $this;
211
    }
212
}
213