1
|
|
|
<?php |
2
|
|
|
namespace Sender\Otp; |
3
|
|
|
|
4
|
|
|
use Sender\Deliver; |
5
|
|
|
use Sender\Validation; |
6
|
|
|
use Sender\Otp\OtpSend; |
7
|
|
|
use Sender\MobileNumber; |
8
|
|
|
use Sender\Traits\OtpBuildTrait; |
9
|
|
|
use Sender\Traits\SmsOtpCommonTrait; |
10
|
|
|
use Sender\Config\Config as ConfigClass; |
11
|
|
|
use Sender\ExceptionClass\ParameterException; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* This Class for build OTP |
15
|
|
|
* |
16
|
|
|
* @package Sender\OtpClass |
17
|
|
|
* @author VenkatS <[email protected]> |
18
|
|
|
* @link https://github.com/tesark/msg91-php |
19
|
|
|
* @license MIT |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
class OtpDefineClass |
23
|
|
|
{ |
24
|
|
|
use OtpBuildTrait; |
25
|
|
|
use SmsOtpCommonTrait; |
26
|
|
|
/** |
27
|
|
|
* @var array $inputData |
28
|
|
|
*/ |
29
|
|
|
protected $inputData = null; |
30
|
|
|
/** |
31
|
|
|
* @var array $sendData |
32
|
|
|
*/ |
33
|
|
|
protected $sendData = null; |
34
|
|
|
/** |
35
|
|
|
* @var string $message |
36
|
|
|
*/ |
37
|
|
|
protected $message = null; |
38
|
|
|
/** |
39
|
|
|
* @var string $sender |
40
|
|
|
*/ |
41
|
|
|
protected $sender = null; |
42
|
|
|
/** |
43
|
|
|
* @var int $otp |
44
|
|
|
*/ |
45
|
|
|
protected $otp = null; |
46
|
|
|
/** |
47
|
|
|
* @var int $otpExpiry |
48
|
|
|
*/ |
49
|
|
|
protected $otpExpiry = null; |
50
|
|
|
/** |
51
|
|
|
* @var int $otpLength |
52
|
|
|
*/ |
53
|
|
|
protected $otpLength = null; |
54
|
|
|
/** |
55
|
|
|
* @var string $authkey |
56
|
|
|
*/ |
57
|
|
|
protected $authkey = null; |
58
|
|
|
/** |
59
|
|
|
* @var int $mobile |
60
|
|
|
*/ |
61
|
|
|
protected $mobile = null; |
62
|
|
|
/** |
63
|
|
|
* @var string $retrytype |
64
|
|
|
*/ |
65
|
|
|
protected $retrytype = null; |
66
|
|
|
/** |
67
|
|
|
* Check the data empty |
68
|
|
|
* @return bool |
69
|
|
|
*/ |
70
|
15 |
|
protected function hasInputData() |
71
|
|
|
{ |
72
|
15 |
|
return isset($this->inputData); |
73
|
|
|
} |
74
|
|
|
/** |
75
|
|
|
* Check the sendData empty |
76
|
|
|
* @return bool |
77
|
|
|
*/ |
78
|
20 |
|
protected function hasSendData() |
79
|
|
|
{ |
80
|
20 |
|
return isset($this->sendData); |
81
|
|
|
} |
82
|
|
|
/** |
83
|
|
|
* set message |
84
|
|
|
* @return bool |
85
|
|
|
*/ |
86
|
3 |
|
protected function setMessage() |
87
|
|
|
{ |
88
|
3 |
|
$this->message = $this->inputData['message']; |
89
|
3 |
|
return true; |
90
|
|
|
} |
91
|
|
|
/* |
92
|
|
|
* get message |
93
|
|
|
*/ |
94
|
3 |
|
protected function getMessage() |
95
|
|
|
{ |
96
|
3 |
|
return $this->message; |
97
|
|
|
} |
98
|
|
|
/** |
99
|
|
|
* set sender |
100
|
|
|
* @return bool |
101
|
|
|
*/ |
102
|
15 |
|
protected function setSender() |
103
|
|
|
{ |
104
|
15 |
|
$this->sender = $this->inputData['sender']; |
105
|
15 |
|
return true; |
106
|
|
|
} |
107
|
|
|
/* |
108
|
|
|
* get sender |
109
|
|
|
*/ |
110
|
15 |
|
protected function getSender() |
111
|
|
|
{ |
112
|
15 |
|
return $this->sender; |
113
|
|
|
} |
114
|
|
|
/** |
115
|
|
|
* set otp |
116
|
|
|
* @return bool |
117
|
|
|
*/ |
118
|
2 |
|
protected function setOtp() |
119
|
|
|
{ |
120
|
2 |
|
$this->otp = $this->inputData['otp']; |
121
|
2 |
|
return true; |
122
|
|
|
} |
123
|
|
|
/* |
124
|
|
|
* get otp |
125
|
|
|
*/ |
126
|
2 |
|
protected function getOtp() |
127
|
|
|
{ |
128
|
2 |
|
return $this->otp; |
129
|
|
|
} |
130
|
|
|
/** |
131
|
|
|
* set otp |
132
|
|
|
* @return bool |
133
|
|
|
*/ |
134
|
|
|
protected function setOneTimePass() |
135
|
|
|
{ |
136
|
|
|
$this->otp = $this->sendData['otp']; |
137
|
|
|
return true; |
138
|
|
|
} |
139
|
|
|
/* |
140
|
|
|
* get setonetime |
141
|
|
|
*/ |
142
|
|
|
protected function getOneTimePass() |
143
|
|
|
{ |
144
|
|
|
return $this->otp; |
145
|
|
|
} |
146
|
|
|
/** |
147
|
|
|
* set otp_expiry |
148
|
|
|
* @return bool |
149
|
|
|
*/ |
150
|
9 |
|
protected function setOtpExpiry() |
151
|
|
|
{ |
152
|
9 |
|
$this->otpExpiry = $this->inputData['otp_expiry']; |
153
|
9 |
|
return true; |
154
|
|
|
} |
155
|
|
|
/* |
156
|
|
|
* get otp_expiry |
157
|
|
|
*/ |
158
|
9 |
|
protected function getOtpExpiry() |
159
|
|
|
{ |
160
|
9 |
|
return $this->otpExpiry; |
161
|
|
|
} |
162
|
|
|
/** |
163
|
|
|
* set otp_length |
164
|
|
|
* @return bool |
165
|
|
|
*/ |
166
|
6 |
|
protected function setOtpLength() |
167
|
|
|
{ |
168
|
6 |
|
$this->otpLength = $this->inputData['otp_length']; |
169
|
6 |
|
return true; |
170
|
|
|
} |
171
|
|
|
/* |
172
|
|
|
* get otp_length |
173
|
|
|
*/ |
174
|
6 |
|
protected function getOtpLength() |
175
|
|
|
{ |
176
|
6 |
|
return $this->otpLength; |
177
|
|
|
} |
178
|
|
|
/** |
179
|
|
|
* set authkey |
180
|
|
|
* @return bool |
181
|
|
|
*/ |
182
|
20 |
|
protected function setAuthkey() |
183
|
|
|
{ |
184
|
20 |
|
$this->authkey = $this->sendData['authkey']; |
185
|
20 |
|
return true; |
186
|
|
|
} |
187
|
|
|
/* |
188
|
|
|
* get authkey |
189
|
|
|
*/ |
190
|
20 |
|
protected function getAuthkey() |
191
|
|
|
{ |
192
|
20 |
|
return $this->authkey; |
193
|
|
|
} |
194
|
|
|
/** |
195
|
|
|
* set mobile |
196
|
|
|
* @return bool |
197
|
|
|
*/ |
198
|
20 |
|
protected function setmobile() |
199
|
|
|
{ |
200
|
20 |
|
$this->mobile = $this->sendData['mobile']; |
201
|
20 |
|
return true; |
202
|
|
|
} |
203
|
|
|
/* |
204
|
|
|
* get mobile |
205
|
|
|
*/ |
206
|
20 |
|
protected function getmobile() |
207
|
|
|
{ |
208
|
20 |
|
return $this->mobile; |
209
|
|
|
} |
210
|
|
|
/** |
211
|
|
|
* set retrytype |
212
|
|
|
* @return bool |
213
|
|
|
*/ |
214
|
4 |
|
protected function setRetryType() |
215
|
|
|
{ |
216
|
4 |
|
$this->retrytype = $this->sendData['retrytype']; |
217
|
4 |
|
return true; |
218
|
|
|
} |
219
|
|
|
/* |
220
|
|
|
* get retrytype |
221
|
|
|
*/ |
222
|
4 |
|
protected function getRetryType() |
223
|
|
|
{ |
224
|
4 |
|
return $this->retrytype; |
225
|
|
|
} |
226
|
|
|
} |
227
|
|
|
|