1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TelegramBot\Api\Types\Inline\QueryResult; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class InlineQueryResultPhoto |
7
|
|
|
* Represents a link to a photo. By default, this photo will be sent by the user with optional caption. |
8
|
|
|
* Alternatively, you can provide message_text to send it instead of photo. |
9
|
|
|
* |
10
|
|
|
* @package TelegramBot\Api\Types\Inline |
11
|
|
|
*/ |
12
|
|
View Code Duplication |
class Photo extends AbstractInlineQueryResult |
|
|
|
|
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* {@inheritdoc} |
16
|
|
|
* |
17
|
|
|
* @var array |
18
|
|
|
*/ |
19
|
|
|
static protected $requiredParams = ['type', 'id', 'photo_url', 'thumb_url']; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* {@inheritdoc} |
23
|
|
|
* |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
static protected $map = [ |
27
|
|
|
'type' => true, |
28
|
|
|
'id' => true, |
29
|
|
|
'photo_url' => true, |
30
|
|
|
'mime_type' => true, |
31
|
|
|
'photo_width' => true, |
32
|
|
|
'photo_height' => true, |
33
|
|
|
'thumb_url' => true, |
34
|
|
|
'title' => true, |
35
|
|
|
'description' => true, |
36
|
|
|
'caption' => true, |
37
|
|
|
'message_text' => true, |
38
|
|
|
'parse_mode' => true, |
39
|
|
|
'disable_web_page_preview' => true, |
40
|
|
|
]; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $type = 'photo'; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* A valid URL of the photo. Photo size must not exceed 5MB |
51
|
|
|
* |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
protected $photoUrl; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Optional. MIME type of the photo, defaults to image/jpeg |
58
|
|
|
* |
59
|
|
|
* @var string |
60
|
|
|
*/ |
61
|
|
|
protected $mimeType; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Optional. Width of the photo |
65
|
|
|
* |
66
|
|
|
* @var int |
67
|
|
|
*/ |
68
|
|
|
protected $photoWidth; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Optional. Height of the photo |
72
|
|
|
* |
73
|
|
|
* @var int |
74
|
|
|
*/ |
75
|
|
|
protected $photoHeight; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* URL of the thumbnail for the photo |
79
|
|
|
* |
80
|
|
|
* @var |
81
|
|
|
*/ |
82
|
|
|
protected $thumbUrl; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Optional. Short description of the result |
86
|
|
|
* |
87
|
|
|
* @var string |
88
|
|
|
*/ |
89
|
|
|
protected $description; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Optional. Caption of the photo to be sent, 0-200 characters |
93
|
|
|
* |
94
|
|
|
* @var string |
95
|
|
|
*/ |
96
|
|
|
protected $caption; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* InlineQueryResultPhoto constructor. |
100
|
|
|
* |
101
|
|
|
* @param string $id |
102
|
|
|
* @param string $photoUrl |
103
|
|
|
* @param string $thumbUrl |
104
|
|
|
* @param string|null $mimeType |
105
|
|
|
* @param int|null $photoWidth |
106
|
|
|
* @param int|null $photoHeight |
107
|
|
|
* @param string|null $title |
108
|
|
|
* @param string|null $description |
109
|
|
|
* @param string|null $caption |
110
|
|
|
* @param string|null $messageText |
111
|
|
|
* @param string|null $parseMode |
112
|
|
|
* @param bool|null $disableWebPagePreview |
113
|
|
|
*/ |
114
|
|
|
public function __construct( |
115
|
|
|
$id, |
116
|
|
|
$photoUrl, |
117
|
|
|
$thumbUrl, |
118
|
|
|
$mimeType = null, |
119
|
|
|
$photoWidth = null, |
120
|
|
|
$photoHeight = null, |
121
|
|
|
$title = null, |
122
|
|
|
$description = null, |
123
|
|
|
$caption = null, |
124
|
|
|
$messageText = null, |
125
|
|
|
$parseMode = null, |
126
|
|
|
$disableWebPagePreview = null |
127
|
|
|
) { |
128
|
|
|
parent::__construct($id, $title, $messageText, $parseMode, $disableWebPagePreview); |
|
|
|
|
129
|
|
|
|
130
|
|
|
$this->photoUrl = $photoUrl; |
131
|
|
|
$this->thumbUrl = $thumbUrl; |
132
|
|
|
$this->mimeType = $mimeType; |
133
|
|
|
$this->photoWidth = $photoWidth; |
134
|
|
|
$this->photoHeight = $photoHeight; |
135
|
|
|
$this->description = $description; |
136
|
|
|
$this->caption = $caption; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return string |
142
|
|
|
*/ |
143
|
|
|
public function getPhotoUrl() |
144
|
|
|
{ |
145
|
|
|
return $this->photoUrl; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param string $photoUrl |
150
|
|
|
*/ |
151
|
|
|
public function setPhotoUrl($photoUrl) |
152
|
|
|
{ |
153
|
|
|
$this->photoUrl = $photoUrl; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return string |
158
|
|
|
*/ |
159
|
|
|
public function getMimeType() |
160
|
|
|
{ |
161
|
|
|
return $this->mimeType; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param string $mimeType |
166
|
|
|
*/ |
167
|
|
|
public function setMimeType($mimeType) |
168
|
|
|
{ |
169
|
|
|
$this->mimeType = $mimeType; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @return int |
174
|
|
|
*/ |
175
|
|
|
public function getPhotoWidth() |
176
|
|
|
{ |
177
|
|
|
return $this->photoWidth; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @param int $photoWidth |
182
|
|
|
*/ |
183
|
|
|
public function setPhotoWidth($photoWidth) |
184
|
|
|
{ |
185
|
|
|
$this->photoWidth = $photoWidth; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @return int |
190
|
|
|
*/ |
191
|
|
|
public function getPhotoHeight() |
192
|
|
|
{ |
193
|
|
|
return $this->photoHeight; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @param int $photoHeight |
198
|
|
|
*/ |
199
|
|
|
public function setPhotoHeight($photoHeight) |
200
|
|
|
{ |
201
|
|
|
$this->photoHeight = $photoHeight; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return mixed |
206
|
|
|
*/ |
207
|
|
|
public function getThumbUrl() |
208
|
|
|
{ |
209
|
|
|
return $this->thumbUrl; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @param mixed $thumbUrl |
214
|
|
|
*/ |
215
|
|
|
public function setThumbUrl($thumbUrl) |
216
|
|
|
{ |
217
|
|
|
$this->thumbUrl = $thumbUrl; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @return string |
222
|
|
|
*/ |
223
|
|
|
public function getDescription() |
224
|
|
|
{ |
225
|
|
|
return $this->description; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param string $description |
230
|
|
|
*/ |
231
|
|
|
public function setDescription($description) |
232
|
|
|
{ |
233
|
|
|
$this->description = $description; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @return string |
238
|
|
|
*/ |
239
|
|
|
public function getCaption() |
240
|
|
|
{ |
241
|
|
|
return $this->caption; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param string $caption |
246
|
|
|
*/ |
247
|
|
|
public function setCaption($caption) |
248
|
|
|
{ |
249
|
|
|
$this->caption = $caption; |
250
|
|
|
} |
251
|
|
|
} |
252
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.