1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is a part of the Yoqut package. |
5
|
|
|
* |
6
|
|
|
* (c) Sukhrob Khakimov <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that is distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Yoqut\Component\Sms\Model; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* The default gateway implementation |
16
|
|
|
* |
17
|
|
|
* @author Sukhrob Khakimov <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class Gateway implements GatewayInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* The unique id of a gateway |
23
|
|
|
* |
24
|
|
|
* @var mixed |
25
|
|
|
*/ |
26
|
|
|
protected $id; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* The name of a gateway |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
protected $name; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The host of a gateway |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $host; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* The port of a gateway |
44
|
|
|
* |
45
|
|
|
* @var integer |
46
|
|
|
*/ |
47
|
|
|
protected $port; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* The interfaceVersion of a gateway |
51
|
|
|
* |
52
|
|
|
* @var integer |
53
|
|
|
*/ |
54
|
|
|
protected $interfaceVersion; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* The username of a gateway |
58
|
|
|
* |
59
|
|
|
* @var string |
60
|
|
|
*/ |
61
|
|
|
protected $username; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* The password of a gateway |
65
|
|
|
* |
66
|
|
|
* @var string |
67
|
|
|
*/ |
68
|
|
|
protected $password; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* The service numbers of a gateway |
72
|
|
|
* |
73
|
|
|
* @var array |
74
|
|
|
*/ |
75
|
|
|
protected $serviceNumbers; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* The prefix codes of a gateway |
79
|
|
|
* |
80
|
|
|
* @var array |
81
|
|
|
*/ |
82
|
|
|
protected $prefixCodes; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* The default configurations of a gateway |
86
|
|
|
* |
87
|
|
|
* @var array |
88
|
|
|
*/ |
89
|
|
|
protected $configs = array( |
90
|
|
|
'persistent' => false, |
91
|
|
|
'debug' => false, |
92
|
|
|
'send_timeout' => 10000, |
93
|
|
|
'receive_timeout' => 10000, |
94
|
|
|
'sender' => array( |
95
|
|
|
'ton' => \SMPP::TON_UNKNOWN, |
96
|
|
|
'npi' => \SMPP::NPI_UNKNOWN |
97
|
|
|
), |
98
|
|
|
'recipient' => array( |
99
|
|
|
'ton' => \SMPP::TON_INTERNATIONAL, |
100
|
|
|
'npi' => \SMPP::NPI_E164 |
101
|
|
|
) |
102
|
|
|
); |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Constructor |
106
|
|
|
* |
107
|
|
|
* @param string $host |
108
|
|
|
* @param integer $port |
109
|
|
|
* @param integer $interfaceVersion |
110
|
|
|
* @param string $username |
111
|
|
|
* @param string $password |
112
|
|
|
* @param array $serviceNumbers |
113
|
|
|
* @param array $prefixCodes |
114
|
|
|
* @param array $configs |
115
|
|
|
*/ |
116
|
|
|
public function __construct( |
117
|
|
|
$host, |
118
|
|
|
$port, |
119
|
|
|
$interfaceVersion, |
120
|
|
|
$username, |
121
|
|
|
$password, |
122
|
|
|
array $serviceNumbers = array(), |
123
|
|
|
array $prefixCodes = array(), |
124
|
|
|
array $configs = array() |
125
|
|
|
) { |
126
|
|
|
$this->host = $host; |
127
|
|
|
$this->port = $port; |
128
|
|
|
$this->interfaceVersion = $interfaceVersion; |
129
|
|
|
$this->username = $username; |
130
|
|
|
$this->password = $password; |
131
|
|
|
$this->serviceNumbers = $serviceNumbers; |
132
|
|
|
$this->prefixCodes = $prefixCodes; |
133
|
|
|
$this->configs = array_replace_recursive($this->configs, $configs); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Gets the id |
138
|
|
|
* |
139
|
|
|
* @return mixed |
140
|
|
|
*/ |
141
|
|
|
public function getId() |
142
|
|
|
{ |
143
|
|
|
return $this->id; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* {@inheritDoc} |
148
|
|
|
*/ |
149
|
|
|
public function setName($name) |
150
|
|
|
{ |
151
|
|
|
$this->name = $name; |
152
|
|
|
|
153
|
|
|
return $this; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* {@inheritDoc} |
158
|
|
|
*/ |
159
|
|
|
public function getName() |
160
|
|
|
{ |
161
|
|
|
return $this->name; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* {@inheritDoc} |
166
|
|
|
*/ |
167
|
|
|
public function getHost() |
168
|
|
|
{ |
169
|
|
|
return $this->host; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* {@inheritDoc} |
174
|
|
|
*/ |
175
|
|
|
public function getPort() |
176
|
|
|
{ |
177
|
|
|
return $this->port; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* {@inheritDoc} |
182
|
|
|
*/ |
183
|
|
|
public function getInterfaceVersion() |
184
|
|
|
{ |
185
|
|
|
return $this->interfaceVersion; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* {@inheritDoc} |
190
|
|
|
*/ |
191
|
|
|
public function getUsername() |
192
|
|
|
{ |
193
|
|
|
return $this->username; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* {@inheritDoc} |
198
|
|
|
*/ |
199
|
|
|
public function getPassword() |
200
|
|
|
{ |
201
|
|
|
return $this->password; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* {@inheritDoc} |
206
|
|
|
*/ |
207
|
|
|
public function getServiceNumbers() |
208
|
|
|
{ |
209
|
|
|
return $this->serviceNumbers; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* {@inheritDoc} |
214
|
|
|
*/ |
215
|
|
|
public function getPrefixCodes() |
216
|
|
|
{ |
217
|
|
|
return $this->prefixCodes; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* {@inheritDoc} |
222
|
|
|
*/ |
223
|
|
|
public function getConfigs() |
224
|
|
|
{ |
225
|
|
|
return $this->configs; |
226
|
|
|
} |
227
|
|
|
} |
228
|
|
|
|