|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: iGusev |
|
5
|
|
|
* Date: 13/04/16 |
|
6
|
|
|
* Time: 04:10 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace TelegramBot\Api\Types; |
|
10
|
|
|
|
|
11
|
|
|
use TelegramBot\Api\BaseType; |
|
12
|
|
|
use TelegramBot\Api\TypeInterface; |
|
13
|
|
|
|
|
14
|
|
|
class MessageEntity extends BaseType implements TypeInterface |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
|
|
const TYPE_MENTION = 'mention'; |
|
18
|
|
|
const TYPE_HASHTAG = 'hashtag'; |
|
19
|
|
|
const TYPE_CASHTAG = 'cashtag'; |
|
20
|
|
|
const TYPE_BOT_COMMAND = 'bot_command'; |
|
21
|
|
|
const TYPE_URL = 'url'; |
|
22
|
|
|
const TYPE_EMAIL = 'email'; |
|
23
|
|
|
const TYPE_PHONE_NUMBER = 'phone_number'; |
|
24
|
|
|
const TYPE_BOLD = 'bold'; |
|
25
|
|
|
const TYPE_ITALIC = 'italic'; |
|
26
|
|
|
const TYPE_UNDERLINE = 'underline'; |
|
27
|
|
|
const TYPE_STRIKETHROUGH = 'strikethrough'; |
|
28
|
|
|
const TYPE_CODE = 'code'; |
|
29
|
|
|
const TYPE_PRE = 'pre'; |
|
30
|
|
|
const TYPE_TEXT_LINK = 'text_link'; |
|
31
|
|
|
const TYPE_TEXT_MENTION = 'text_mention'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritdoc} |
|
35
|
|
|
* |
|
36
|
|
|
* @var array |
|
37
|
|
|
*/ |
|
38
|
|
|
static protected $requiredParams = ['type', 'offset', 'length']; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* {@inheritdoc} |
|
42
|
|
|
* |
|
43
|
|
|
* @var array |
|
44
|
|
|
*/ |
|
45
|
|
|
static protected $map = [ |
|
46
|
|
|
'type' => true, |
|
47
|
|
|
'offset' => true, |
|
48
|
|
|
'length' => true, |
|
49
|
|
|
'url' => true, |
|
50
|
|
|
'user' => true, |
|
51
|
|
|
'language' => true, |
|
52
|
|
|
]; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Type of the entity. |
|
56
|
|
|
* One of mention (@username), hashtag (#hashtag), cashtag ($USD), bot_command, url, email, phone_number, |
|
57
|
|
|
* bold (bold text), italic (italic text), underline (underlined text), strikethrough (strikethrough text), |
|
58
|
|
|
* code (monowidth string), pre (monowidth block), text_link (for clickable text URLs), |
|
59
|
|
|
* text_mention (for users without usernames) |
|
60
|
|
|
* |
|
61
|
|
|
* @var string |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $type; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Offset in UTF-16 code units to the start of the entity |
|
67
|
|
|
* |
|
68
|
|
|
* @var int |
|
69
|
|
|
*/ |
|
70
|
|
|
protected $offset; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Length of the entity in UTF-16 code units |
|
74
|
|
|
* |
|
75
|
|
|
* @var int |
|
76
|
|
|
*/ |
|
77
|
|
|
protected $length; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Optional. For “text_link” only, url that will be opened after user taps on the text |
|
81
|
|
|
* |
|
82
|
|
|
* @var string |
|
83
|
|
|
*/ |
|
84
|
|
|
protected $url; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Optional. For “text_mention” only, the mentioned user |
|
88
|
|
|
* |
|
89
|
|
|
* @var User |
|
90
|
|
|
*/ |
|
91
|
|
|
protected $user; |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Optional. For “pre” only, the programming language of the entity text |
|
95
|
|
|
* |
|
96
|
|
|
* @var string |
|
97
|
|
|
*/ |
|
98
|
|
|
protected $language; |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @return string |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getType() |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->type; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @param string $type |
|
110
|
|
|
*/ |
|
111
|
1 |
|
public function setType($type) |
|
112
|
|
|
{ |
|
113
|
1 |
|
$this->type = $type; |
|
114
|
1 |
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @return int |
|
118
|
|
|
*/ |
|
119
|
|
|
public function getOffset() |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->offset; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @param int $offset |
|
126
|
|
|
*/ |
|
127
|
1 |
|
public function setOffset($offset) |
|
128
|
|
|
{ |
|
129
|
1 |
|
$this->offset = $offset; |
|
130
|
1 |
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @return int |
|
134
|
|
|
*/ |
|
135
|
|
|
public function getLength() |
|
136
|
|
|
{ |
|
137
|
|
|
return $this->length; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @param int $length |
|
142
|
|
|
*/ |
|
143
|
1 |
|
public function setLength($length) |
|
144
|
|
|
{ |
|
145
|
1 |
|
$this->length = $length; |
|
146
|
1 |
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* @return string |
|
150
|
|
|
*/ |
|
151
|
|
|
public function getUrl() |
|
152
|
|
|
{ |
|
153
|
|
|
return $this->url; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @param string $url |
|
158
|
|
|
*/ |
|
159
|
|
|
public function setUrl($url) |
|
160
|
|
|
{ |
|
161
|
|
|
$this->url = $url; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* @return User |
|
166
|
|
|
*/ |
|
167
|
|
|
public function getUser() |
|
168
|
|
|
{ |
|
169
|
|
|
return $this->user; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* @param User $user |
|
174
|
|
|
*/ |
|
175
|
|
|
public function setUser($user) |
|
176
|
|
|
{ |
|
177
|
|
|
$this->user = $user; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* @return string |
|
182
|
|
|
*/ |
|
183
|
|
|
public function getLanguage() |
|
184
|
|
|
{ |
|
185
|
|
|
return $this->language; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* @param string $language |
|
190
|
|
|
*/ |
|
191
|
|
|
public function setLanguage($language) |
|
192
|
|
|
{ |
|
193
|
|
|
$this->language = $language; |
|
194
|
|
|
} |
|
195
|
|
|
} |
|
196
|
|
|
|