Article::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 16
ccs 0
cts 15
cp 0
rs 10
cc 1
nc 1
nop 8
crap 2

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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 InlineQueryResultArticle
10
 * Represents a link to an article or web page.
11
 *
12
 * @package TelegramBot\Api\Types\Inline
13
 */
14
class Article extends AbstractInlineQueryResult
15
{
16
    /**
17
     * {@inheritdoc}
18
     *
19
     * @var array
20
     */
21
    protected static $requiredParams = ['type', 'id', 'title', 'input_message_content'];
22
23
    /**
24
     * {@inheritdoc}
25
     *
26
     * @var array
27
     */
28
    protected static $map = [
29
        'type' => true,
30
        'id' => true,
31
        'title' => true,
32
        'input_message_content' => InputMessageContent::class,
33
        'reply_markup' => InlineKeyboardMarkup::class,
34
        'url' => true,
35
        'hide_url' => true,
36
        'description' => true,
37
        'thumbnail_url' => true,
38
        'thumbnail_width' => true,
39
        'thumbnail_height' => true,
40
    ];
41
42
    /**
43
     * {@inheritdoc}
44
     *
45
     * @var string
46
     */
47
    protected $type = 'article';
48
49
    /**
50
     * Optional. URL of the result
51
     *
52
     * @var string|null
53
     */
54
    protected $url;
55
56
    /**
57
     * Optional. Pass True, if you don't want the URL to be shown in the message
58
     *
59
     * @var bool|null
60
     */
61
    protected $hideUrl;
62
63
    /**
64
     * Optional. Short description of the result
65
     *
66
     * @var string|null
67
     */
68
    protected $description;
69
70
    /**
71
     * Optional. Url of the thumbnail for the result
72
     *
73
     * @var string|null
74
     */
75
    protected $thumbnailUrl;
76
77
    /**
78
     * Optional. Thumbnail width
79
     *
80
     * @var int|null
81
     */
82
    protected $thumbnailWidth;
83
84
    /**
85
     * Optional. Thumbnail height
86
     *
87
     * @var int|null
88
     */
89
    protected $thumbnailHeight;
90
91
    /**
92
     * InlineQueryResultArticle constructor.
93
     *
94
     * @param string $id
95
     * @param string $title
96
     * @param string|null $description
97
     * @param string|null $thumbnailUrl
98
     * @param int|null $thumbnailWidth
99
     * @param int|null $thumbnailHeight
100
     * @param InputMessageContent $inputMessageContent
101
     * @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
102
     */
103
    public function __construct(
104
        $id,
105
        $title,
106
        $description = null,
107
        $thumbnailUrl = null,
108
        $thumbnailWidth = null,
109
        $thumbnailHeight = null,
110
        $inputMessageContent = null,
111
        $inlineKeyboardMarkup = null
112
    ) {
113
        parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
114
115
        $this->description = $description;
116
        $this->thumbnailUrl = $thumbnailUrl;
117
        $this->thumbnailWidth = $thumbnailWidth;
118
        $this->thumbnailHeight = $thumbnailHeight;
119
    }
120
121
    /**
122
     * @return string|null
123
     */
124
    public function getUrl()
125
    {
126
        return $this->url;
127
    }
128
129
    /**
130
     * @param string|null $url
131
     *
132
     * @return void
133
     */
134
    public function setUrl($url)
135
    {
136
        $this->url = $url;
137
    }
138
139
    /**
140
     * @return bool|null
141
     */
142
    public function isHideUrl()
143
    {
144
        return $this->hideUrl;
145
    }
146
147
    /**
148
     * @param bool|null $hideUrl
149
     *
150
     * @return void
151
     */
152
    public function setHideUrl($hideUrl)
153
    {
154
        $this->hideUrl = $hideUrl;
155
    }
156
157
    /**
158
     * @return string|null
159
     */
160
    public function getDescription()
161
    {
162
        return $this->description;
163
    }
164
165
    /**
166
     * @param string|null $description
167
     *
168
     * @return void
169
     */
170
    public function setDescription($description)
171
    {
172
        $this->description = $description;
173
    }
174
175
    /**
176
     * @return string|null
177
     */
178
    public function getThumbnailUrl()
179
    {
180
        return $this->thumbnailUrl;
181
    }
182
183
    /**
184
     * @param string|null $thumbnailUrl
185
     *
186
     * @return void
187
     */
188
    public function setThumbnailUrl($thumbnailUrl)
189
    {
190
        $this->thumbnailUrl = $thumbnailUrl;
191
    }
192
193
    /**
194
     * @deprecated Use getThumbnailUrl
195
     *
196
     * @return string|null
197
     */
198
    public function getThumbUrl()
199
    {
200
        return $this->getThumbnailUrl();
201
    }
202
203
    /**
204
     * @deprecated Use setThumbnailUrl
205
     *
206
     * @param string|null $thumbUrl
207
     *
208
     * @return void
209
     */
210
    public function setThumbUrl($thumbUrl)
211
    {
212
        $this->setThumbnailUrl($thumbUrl);
213
    }
214
215
    /**
216
     * @return int|null
217
     */
218
    public function getThumbnailWidth()
219
    {
220
        return $this->thumbnailWidth;
221
    }
222
223
    /**
224
     * @param int|null $thumbnailWidth
225
     *
226
     * @return void
227
     */
228
    public function setThumbnailWidth($thumbnailWidth)
229
    {
230
        $this->thumbnailWidth = $thumbnailWidth;
231
    }
232
233
    /**
234
     * @deprecated Use getThumbnailWidth
235
     *
236
     * @return int|null
237
     */
238
    public function getThumbWidth()
239
    {
240
        return $this->getThumbnailWidth();
241
    }
242
243
    /**
244
     * @deprecated Use setThumbnailWidth
245
     *
246
     * @param int|null $thumbWidth
247
     *
248
     * @return void
249
     */
250
    public function setThumbWidth($thumbWidth)
251
    {
252
        $this->setThumbnailWidth($thumbWidth);
253
    }
254
255
    /**
256
     * @return int|null
257
     */
258
    public function getThumbnailHeight()
259
    {
260
        return $this->thumbnailHeight;
261
    }
262
263
    /**
264
     * @param int|null $thumbnailHeight
265
     *
266
     * @return void
267
     */
268
    public function setThumbnailHeight($thumbnailHeight)
269
    {
270
        $this->thumbnailHeight = $thumbnailHeight;
271
    }
272
273
    /**
274
     * @deprecated Use getThumbnailHeight
275
     *
276
     * @return int|null
277
     */
278
    public function getThumbHeight()
279
    {
280
        return $this->getThumbnailHeight();
281
    }
282
283
    /**
284
     * @deprecated Use setThumbnailWidth
285
     *
286
     * @param int|null $thumbHeight
287
     *
288
     * @return void
289
     */
290
    public function setThumbHeight($thumbHeight)
291
    {
292
        $this->setThumbnailHeight($thumbHeight);
293
    }
294
}
295