1 | <?php |
||
24 | final class Message { |
||
25 | /** |
||
26 | * Message statuses |
||
27 | */ |
||
28 | const STATUS_DELIVERED = 0, // the message was delivered to the subscriber |
||
29 | STATUS_BUFFERED = 1, // the message is queued at SMSC |
||
30 | STATUS_ABSENT = 2, // the subscriber is out of coverage. Message is queued |
||
31 | STATUS_PREPARING = 3, // the message is being prepared for delivery |
||
32 | STATUS_UNKNOWN = 4, // no reply from mobile network operator |
||
33 | STATUS_NOT_DELIVERED = -1, // message was not delivered |
||
34 | STATUS_EXPIRED = -2, // message expired and deleted from the SMSC |
||
35 | STATUS_REJECTED = -3; // delivery rejected by the mobile network operator |
||
36 | |||
37 | /** |
||
38 | * Maximum message delay, seconds |
||
39 | */ |
||
40 | const MAX_DELAY = 10080; |
||
41 | |||
42 | /** |
||
43 | * Message type: text or binary |
||
44 | */ |
||
45 | const TYPE_TEXT = 0, |
||
46 | TYPE_BINARY = 1; |
||
47 | |||
48 | /** |
||
49 | * Delivery report constants |
||
50 | */ |
||
51 | const NO_DELIVERY_REPORT = 0, |
||
52 | DELIVERY_REPORT = 1; |
||
53 | |||
54 | /** |
||
55 | * @var int message type |
||
56 | */ |
||
57 | private $type = self::TYPE_TEXT; |
||
58 | |||
59 | /** |
||
60 | * @var int delivery message delay |
||
61 | */ |
||
62 | private $delay = 0; |
||
63 | |||
64 | /** |
||
65 | * @var bool need delivery message report or not |
||
66 | */ |
||
67 | private $needDeliveryReport = false; |
||
68 | |||
69 | /** |
||
70 | * @var int[] phone numbers for message |
||
71 | */ |
||
72 | private $phones = []; |
||
73 | |||
74 | /** |
||
75 | * @return int[] phone numbers for message |
||
76 | */ |
||
77 | 4 | public function getPhones() { |
|
80 | |||
81 | /** |
||
82 | * @param int[] $phones phone numbers for message |
||
83 | * @return $this self instance |
||
84 | */ |
||
85 | 1 | public function setPhones(array $phones) { |
|
89 | |||
90 | /** |
||
91 | * Add phone for delivering method |
||
92 | * @param int $phone phone number |
||
93 | * @return $this self instance |
||
94 | */ |
||
95 | 3 | public function addPhone($phone) { |
|
96 | 3 | $this->phones[] = (int) $phone; |
|
97 | 3 | $this->phones = array_unique($this->phones); |
|
98 | 3 | return $this; |
|
99 | } |
||
100 | |||
101 | /** |
||
102 | * @var string message text |
||
103 | */ |
||
104 | private $text = ''; |
||
105 | |||
106 | /** |
||
107 | * @return string message text |
||
108 | */ |
||
109 | 4 | public function getText() { |
|
112 | |||
113 | /** |
||
114 | * @var string transaction identifier |
||
115 | */ |
||
116 | private $transactionId = ''; |
||
117 | |||
118 | /** |
||
119 | * @return string transaction identifier |
||
120 | */ |
||
121 | 3 | public function getTransactionId() { |
|
124 | |||
125 | /** |
||
126 | * @param string $transactionId transaction identifier |
||
127 | * @return $this self instance |
||
128 | */ |
||
129 | 2 | public function setTransactionId($transactionId) { |
|
133 | |||
134 | /** |
||
135 | * @var null|string session mode prefix |
||
136 | */ |
||
137 | private $prefix = null; |
||
138 | |||
139 | /** |
||
140 | * @return string|null session mode prefix |
||
141 | */ |
||
142 | 3 | public function getPrefix() { |
|
145 | |||
146 | /** |
||
147 | * @param string $prefix session mode prefix |
||
148 | * @return $this self instance |
||
149 | */ |
||
150 | 2 | public function setPrefix($prefix) { |
|
154 | |||
155 | /** |
||
156 | * @var string message charset |
||
157 | */ |
||
158 | private $charset = 'UTF-8'; |
||
159 | |||
160 | /** |
||
161 | * @return string message charset |
||
162 | */ |
||
163 | 3 | public function getCharset() { |
|
166 | |||
167 | /** |
||
168 | * @param string $charset message charset |
||
169 | * @return $this self instance |
||
170 | */ |
||
171 | 2 | public function setCharset($charset) { |
|
175 | |||
176 | /** |
||
177 | * @var null|string message UDH |
||
178 | */ |
||
179 | private $userDataHeader = null; |
||
180 | |||
181 | /** |
||
182 | * @return null|string message UDH |
||
183 | */ |
||
184 | 3 | public function getUserDataHeader() { |
|
187 | |||
188 | /** |
||
189 | * @param string $userDataHeader UDH for message |
||
190 | * @return $this self instance |
||
191 | */ |
||
192 | 2 | public function setUserDataHeader($userDataHeader) { |
|
196 | |||
197 | /** |
||
198 | * @param string $text message text |
||
199 | * @param bool $needDeliveryReport need delivery report or not |
||
200 | * @param int $delay timeout for message delivering, seconds |
||
201 | * @param int $type message type |
||
202 | */ |
||
203 | 4 | public function __construct($text, $needDeliveryReport = false, $delay = 0, $type = self::TYPE_TEXT) { |
|
209 | |||
210 | /** |
||
211 | * Export message state for sending method |
||
212 | * @return string[] message state |
||
213 | */ |
||
214 | 2 | public function export() { |
|
236 | } |
||
237 |