Photo::setPhotoUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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