1
|
|
|
<?php |
2
|
|
|
namespace Sender\Sms; |
3
|
|
|
|
4
|
|
|
use Sender\Deliver; |
5
|
|
|
use Sender\Validation; |
6
|
|
|
use Sender\Sms\SmsBulk; |
7
|
|
|
use Sender\Sms\SmsNormal; |
8
|
|
|
use Sender\MobileNumber; |
9
|
|
|
use Sender\Traits\SmsBuildTrait; |
10
|
|
|
use Sender\Traits\SmsOtpCommonTrait; |
11
|
|
|
use Sender\Traits\SmsBuildSupportTrait; |
12
|
|
|
use Sender\Config\Config as ConfigClass; |
13
|
|
|
use Sender\ExceptionClass\ParameterException; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* This Class for Build and send the SMS |
17
|
|
|
* |
18
|
|
|
* @package Msg91 SMS&OTP package |
19
|
|
|
* @author VenkatS <[email protected]> |
20
|
|
|
* @link https://github.com/tesark/msg91-php |
21
|
|
|
* @license MIT |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
class SmsDefineClass |
25
|
|
|
{ |
26
|
|
|
use SmsBuildTrait; |
27
|
|
|
use SmsOtpCommonTrait; |
28
|
|
|
use SmsBuildSupportTrait; |
29
|
|
|
/** |
30
|
|
|
* @var int $mobile |
31
|
|
|
*/ |
32
|
|
|
protected $mobile = null; |
33
|
|
|
/** |
34
|
|
|
* @var array $inputData |
35
|
|
|
*/ |
36
|
|
|
protected $inputData = null; |
37
|
|
|
/** |
38
|
|
|
* @var string $authkey |
39
|
|
|
*/ |
40
|
|
|
protected $authkey = null; |
41
|
|
|
/** |
42
|
|
|
* @var array $sendData |
43
|
|
|
*/ |
44
|
|
|
protected $sendSmsData = null; |
45
|
|
|
/** |
46
|
|
|
* @var string $message |
47
|
|
|
*/ |
48
|
|
|
protected $message = null; |
49
|
|
|
/** |
50
|
|
|
* @var string|int $unicode |
51
|
|
|
*/ |
52
|
|
|
protected $unicode = null; |
53
|
|
|
/** |
54
|
|
|
* @var string $sender |
55
|
|
|
*/ |
56
|
|
|
protected $sender = null; |
57
|
|
|
/** |
58
|
|
|
* @var string|int $country |
59
|
|
|
*/ |
60
|
|
|
protected $country = null; |
61
|
|
|
/** |
62
|
|
|
* @var string $content |
63
|
|
|
*/ |
64
|
|
|
protected $content = null; |
65
|
|
|
/** |
66
|
|
|
* @var string|int $flash |
67
|
|
|
*/ |
68
|
|
|
protected $flash = null; |
69
|
|
|
/** |
70
|
|
|
* @var string $schtime |
71
|
|
|
*/ |
72
|
|
|
protected $schtime = null; |
73
|
|
|
/** |
74
|
|
|
* @var string $afterminutes |
75
|
|
|
*/ |
76
|
|
|
protected $afterminutes = null; |
77
|
|
|
/** |
78
|
|
|
* @var string $response |
79
|
|
|
*/ |
80
|
|
|
protected $response = null; |
81
|
|
|
/** |
82
|
|
|
* @var string $campaign |
83
|
|
|
*/ |
84
|
|
|
protected $campaign = null; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Check the mobilenumber empty |
88
|
|
|
* @return bool |
89
|
|
|
*/ |
90
|
80 |
|
protected function hasMobileNumber() |
91
|
|
|
{ |
92
|
80 |
|
$data = $this->inputData['mobile']; |
93
|
80 |
|
return isset($data); |
94
|
|
|
} |
95
|
|
|
/** |
96
|
|
|
* Check the data empty |
97
|
|
|
* @return bool |
98
|
|
|
*/ |
99
|
80 |
|
protected function hasData() |
100
|
|
|
{ |
101
|
80 |
|
return isset($this->inputData); |
102
|
|
|
} |
103
|
|
|
/** |
104
|
|
|
* Check the sendData empty |
105
|
|
|
* @return bool |
106
|
|
|
*/ |
107
|
80 |
|
protected function hasSendData() |
108
|
|
|
{ |
109
|
80 |
|
return isset($this->sendSmsData); |
110
|
|
|
} |
111
|
|
|
/** |
112
|
|
|
* This function check variable Key in input array |
113
|
|
|
* @param string $key |
114
|
|
|
* |
115
|
|
|
* @return bool |
116
|
|
|
*/ |
117
|
80 |
|
protected function isKeyPresent($key) |
118
|
|
|
{ |
119
|
80 |
|
return $this->isKeyExists($key, $this->inputData); |
120
|
|
|
} |
121
|
|
|
/** |
122
|
|
|
* set content |
123
|
|
|
* @return bool |
124
|
|
|
*/ |
125
|
|
|
protected function setContent() |
126
|
|
|
{ |
127
|
|
|
$this->content = $this->inputData['content']; |
128
|
|
|
return true; |
129
|
|
|
} |
130
|
|
|
/* |
131
|
|
|
* get content |
132
|
|
|
*/ |
133
|
|
|
protected function getContent() |
134
|
|
|
{ |
135
|
|
|
return $this->content; |
136
|
|
|
} |
137
|
|
|
/** |
138
|
|
|
* set mobile |
139
|
|
|
* @return bool |
140
|
|
|
*/ |
141
|
80 |
|
protected function setMobile() |
142
|
|
|
{ |
143
|
80 |
|
$this->mobile = $this->inputData['mobile']; |
144
|
80 |
|
return true; |
145
|
|
|
} |
146
|
|
|
/* |
147
|
|
|
* get mobile |
148
|
|
|
*/ |
149
|
80 |
|
protected function getMobile() |
150
|
|
|
{ |
151
|
80 |
|
return $this->mobile; |
152
|
|
|
} |
153
|
|
|
/** |
154
|
|
|
* set authkey |
155
|
|
|
* @return bool |
156
|
|
|
*/ |
157
|
|
|
protected function setAuthKey() |
158
|
|
|
{ |
159
|
|
|
$this->authkey = $this->inputData['authkey']; |
160
|
|
|
return true; |
161
|
|
|
} |
162
|
|
|
/* |
163
|
|
|
* get authkey |
164
|
|
|
*/ |
165
|
|
|
protected function getAuthKey() |
166
|
|
|
{ |
167
|
|
|
return $this->authkey; |
168
|
|
|
} |
169
|
|
|
/** |
170
|
|
|
* set message |
171
|
|
|
* @return bool |
172
|
|
|
*/ |
173
|
72 |
|
protected function setMessage() |
174
|
|
|
{ |
175
|
72 |
|
$this->message = $this->inputData['message']; |
176
|
72 |
|
return true; |
177
|
|
|
} |
178
|
|
|
/* |
179
|
|
|
* get message |
180
|
|
|
*/ |
181
|
72 |
|
protected function getMessage() |
182
|
|
|
{ |
183
|
72 |
|
return $this->message; |
184
|
|
|
} |
185
|
|
|
/** |
186
|
|
|
* set unicode |
187
|
|
|
* @return bool |
188
|
|
|
*/ |
189
|
2 |
|
protected function setUnicode() |
190
|
|
|
{ |
191
|
2 |
|
$this->unicode = $this->inputData['unicode']; |
192
|
2 |
|
return true; |
193
|
|
|
} |
194
|
|
|
/* |
195
|
|
|
* get unicode |
196
|
|
|
*/ |
197
|
2 |
|
protected function getUnicode() |
198
|
|
|
{ |
199
|
2 |
|
return $this->unicode; |
200
|
|
|
} |
201
|
|
|
/** |
202
|
|
|
* set sender |
203
|
|
|
* @return bool |
204
|
|
|
*/ |
205
|
58 |
|
protected function setSender() |
206
|
|
|
{ |
207
|
58 |
|
$this->sender = $this->inputData['sender']; |
208
|
58 |
|
return true; |
209
|
|
|
} |
210
|
|
|
/* |
211
|
|
|
* get sender |
212
|
|
|
*/ |
213
|
58 |
|
protected function getSender() |
214
|
|
|
{ |
215
|
58 |
|
return $this->sender; |
216
|
|
|
} |
217
|
|
|
/** |
218
|
|
|
* set country |
219
|
|
|
* @return bool |
220
|
|
|
*/ |
221
|
12 |
|
protected function setCountry() |
222
|
|
|
{ |
223
|
12 |
|
$this->country = $this->inputData['country']; |
224
|
12 |
|
return true; |
225
|
|
|
} |
226
|
|
|
/* |
227
|
|
|
* get country |
228
|
|
|
*/ |
229
|
12 |
|
protected function getCountry() |
230
|
|
|
{ |
231
|
12 |
|
return $this->country; |
232
|
|
|
} |
233
|
|
|
/** |
234
|
|
|
* set flash |
235
|
|
|
* @return bool |
236
|
|
|
*/ |
237
|
4 |
|
protected function setFlash() |
238
|
|
|
{ |
239
|
4 |
|
$this->flash = $this->inputData['flash']; |
240
|
4 |
|
return true; |
241
|
|
|
} |
242
|
|
|
/* |
243
|
|
|
* get flash |
244
|
|
|
*/ |
245
|
4 |
|
protected function getFlash() |
246
|
|
|
{ |
247
|
4 |
|
return $this->flash; |
248
|
|
|
} |
249
|
|
|
/** |
250
|
|
|
* set schtime |
251
|
|
|
* @return bool |
252
|
|
|
*/ |
253
|
20 |
|
protected function setSchtime() |
254
|
|
|
{ |
255
|
20 |
|
$this->schtime = $this->inputData['schtime']; |
256
|
20 |
|
return true; |
257
|
|
|
} |
258
|
|
|
/* |
259
|
|
|
* get schtime |
260
|
|
|
*/ |
261
|
20 |
|
protected function getSchtime() |
262
|
|
|
{ |
263
|
20 |
|
return $this->schtime; |
264
|
|
|
} |
265
|
|
|
/** |
266
|
|
|
* set afterminutes |
267
|
|
|
* @return bool |
268
|
|
|
*/ |
269
|
8 |
|
protected function setAfterminutes() |
270
|
|
|
{ |
271
|
8 |
|
$this->afterminutes = $this->inputData['afterminutes']; |
272
|
8 |
|
return true; |
273
|
|
|
} |
274
|
|
|
/* |
275
|
|
|
* get afterminutes |
276
|
|
|
*/ |
277
|
8 |
|
protected function getAfterminutes() |
278
|
|
|
{ |
279
|
8 |
|
return $this->afterminutes; |
280
|
|
|
} |
281
|
|
|
/** |
282
|
|
|
* set response |
283
|
|
|
* @return bool |
284
|
|
|
*/ |
285
|
6 |
|
protected function setResponse() |
286
|
|
|
{ |
287
|
6 |
|
$this->response = $this->inputData['response']; |
288
|
6 |
|
return true; |
289
|
|
|
} |
290
|
|
|
/* |
291
|
|
|
* get response |
292
|
|
|
*/ |
293
|
6 |
|
protected function getResponse() |
294
|
|
|
{ |
295
|
6 |
|
return $this->response; |
296
|
|
|
} |
297
|
|
|
/** |
298
|
|
|
* set campaign |
299
|
|
|
* @return bool |
300
|
|
|
*/ |
301
|
4 |
|
protected function setCampaign() |
302
|
|
|
{ |
303
|
4 |
|
$this->campaign = $this->inputData['campaign']; |
304
|
4 |
|
return true; |
305
|
|
|
} |
306
|
|
|
/* |
307
|
|
|
* get campaign |
308
|
|
|
*/ |
309
|
4 |
|
protected function getCampaign() |
310
|
|
|
{ |
311
|
4 |
|
return $this->campaign; |
312
|
|
|
} |
313
|
|
|
/** |
314
|
|
|
* Check key present |
315
|
|
|
* @param string $key |
316
|
|
|
* |
317
|
|
|
* @return bool |
318
|
|
|
*/ |
319
|
|
|
public function keyPresent($key) |
320
|
|
|
{ |
321
|
|
|
if ($this->isKeyPresent($key)) { |
322
|
|
|
return true; |
323
|
|
|
} else { |
324
|
|
|
$message = $key."Must be present"; |
325
|
|
|
throw ParameterException::missinglogic($message); |
326
|
|
|
} |
327
|
|
|
} |
328
|
|
|
/** |
329
|
|
|
* This function get Category wise mobile Number |
330
|
|
|
* @param int $category |
331
|
|
|
* |
332
|
|
|
*/ |
333
|
|
|
public function categoryWiseAddedMobile() |
334
|
|
|
{ |
335
|
|
|
if ($this->isKeyExists('mobile', $this->inputData) && $this->setMobile()) { |
336
|
|
|
$value = $this->getMobile(); |
337
|
|
|
return $value; |
338
|
|
|
} else { |
339
|
|
|
$message = "Missing mobile key "; |
340
|
|
|
throw ParameterException::missinglogic($message); |
341
|
|
|
} |
342
|
|
|
} |
343
|
|
|
} |
344
|
|
|
|