Test Setup Failed
Pull Request — master (#306)
by Eldar
06:58
created

Chat::getSlowModeDelay()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace TelegramBot\Api\Types;
4
5
use TelegramBot\Api\BaseType;
6
use TelegramBot\Api\InvalidArgumentException;
7
use TelegramBot\Api\TypeInterface;
8
9
class Chat extends BaseType implements TypeInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     *
14
     * @var array
15
     */
16
    static protected $requiredParams = ['id', 'type'];
17
18
    /**
19
     * {@inheritdoc}
20
     *
21
     * @var array
22
     */
23
    static protected $map = [
24
        'id' => true,
25
        'type' => true,
26
        'title' => true,
27
        'username' => true,
28
        'first_name' => true,
29
        'last_name' => true,
30
        'photo' => ChatPhoto::class,
31
        'bio' => true,
32
        'description' => true,
33
        'invite_link' => true,
34
        'pinned_message' => Message::class,
35
        'permissions' => ChatPermissions::class,
36
        'slow_mode_delay' => true,
37
        'sticker_set_name' => true,
38
        'can_set_sticker_set' => true,
39
        'linked_chat_id' => true,
40
        'location' => ChatLocation::class
41
    ];
42
43
    /**
44
     * Unique identifier for this chat, not exceeding 1e13 by absolute value
45
     *
46
     * @var int|string
47
     */
48
    protected $id;
49
50
    /**
51
     * Type of chat, can be either “private”, “group”, “supergroup” or “channel”
52
     *
53
     * @var string
54
     */
55
    protected $type;
56
57
    /**
58
     * Optional. Title, for channels and group chats
59
     *
60
     * @var string
61
     */
62
    protected $title;
63
64
    /**
65
     * Optional. Username, for private chats and channels if available
66
     *
67
     * @var string
68
     */
69
    protected $username;
70
71
    /**
72
     * Optional. First name of the other party in a private chat
73
     *
74
     * @var string
75
     */
76
    protected $firstName;
77
78
    /**
79
     * Optional. Last name of the other party in a private chat
80
     *
81
     * @var string
82
     */
83
    protected $lastName;
84
85
    /**
86
     * Optional. Chat photo. Returned only in getChat.
87
     *
88
     * @var ChatPhoto
89
     */
90
    protected $photo;
91
92
    /**
93
     * Optional. Bio of the other party in a private chat. Returned only in getChat
94
     *
95
     * @var string
96
     */
97
    protected $bio;
98
99
    /**
100
     * Optional. Description, for supergroups and channel chats. Returned only in getChat.
101
     *
102
     * @var string
103
     */
104
    protected $description;
105
106
    /**
107
     * Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat.
108
     *
109
     * @var string
110
     */
111
    protected $inviteLink;
112
113
    /**
114
     * Optional. Pinned message, for supergroups. Returned only in getChat.
115
     *
116
     * @var Message
117
     */
118
    protected $pinnedMessage;
119
120
    /**
121
     * Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.
122
     *
123
     * @var ChatPermissions
124
     */
125
    protected $permissions;
126
127
    /**
128 3
     * Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged
129
     * user. Returned only in getChat.
130 3
     *
131
     * @var int
132
     */
133
    protected $slowModeDelay;
134
135
    /**
136
     * Optional. For supergroups, name of group sticker set. Returned only in getChat.
137
     *
138 22
     * @var string
139
     */
140 22
    protected $stickerSetName;
141 20
142 20
    /**
143 2
     * Optional. True, if the bot can change the group sticker set. Returned only in getChat.
144
     *
145 20
     * @var bool
146
     */
147
    protected $canSetStickerSet;
148
149
    /**
150 1
     * Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice
151
     * versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming
152 1
     * languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64
153
     * bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat.
154
     *
155
     * @var int
156
     */
157
    protected $linkedChatId;
158 19
159
    /**
160 19
     * Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat.
161 19
     *
162
     * @var ChatLocation
163
     */
164
    protected $location;
165
166 2
    /**
167
     * @return int|string
168 2
     */
169
    public function getId()
170
    {
171
        return $this->id;
172
    }
173
174 13
    /**
175
     * @param int|string $id
176 13
     *
177 13
     * @throws InvalidArgumentException
178
     */
179 View Code Duplication
    public function setId($id)
180
    {
181
        if (is_integer($id) || is_float($id) || is_string($id)) {
182 2
            $this->id = $id;
0 ignored issues
show
Documentation Bug introduced by
It seems like $id can also be of type double. However, the property $id is declared as type integer|string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
183
        } else {
184 2
            throw new InvalidArgumentException();
185
        }
186
    }
187
188
    /**
189
     * @return string
190 8
     */
191
    public function getType()
192 8
    {
193 8
        return $this->type;
194
    }
195
196
    /**
197
     * @param string $type
198 2
     */
199
    public function setType($type)
200 2
    {
201
        $this->type = $type;
202
    }
203
204
    /**
205
     * @return string
206 8
     */
207
    public function getTitle()
208 8
    {
209 8
        return $this->title;
210
    }
211
212
    /**
213
     * @param string $title
214 2
     */
215
    public function setTitle($title)
216 2
    {
217
        $this->title = $title;
218
    }
219
220
    /**
221
     * @return string
222 8
     */
223
    public function getUsername()
224 8
    {
225 8
        return $this->username;
226
    }
227
228
    /**
229
     * @param string $username
230 1
     */
231
    public function setUsername($username)
232 1
    {
233
        $this->username = $username;
234
    }
235
236
    /**
237
     * @return string
238 2
     */
239
    public function getFirstName()
240 2
    {
241 2
        return $this->firstName;
242
    }
243
244
    /**
245
     * @param string $firstName
246 1
     */
247
    public function setFirstName($firstName)
248 1
    {
249
        $this->firstName = $firstName;
250
    }
251
252
    /**
253
     * @return string
254 2
     */
255
    public function getLastName()
256 2
    {
257 2
        return $this->lastName;
258
    }
259
260
    /**
261
     * @param string $lastName
262 1
     */
263
    public function setLastName($lastName)
264 1
    {
265
        $this->lastName = $lastName;
266
    }
267
268
    /**
269
     * @return ChatPhoto
270 2
     */
271
    public function getPhoto()
272 2
    {
273 2
        return $this->photo;
274
    }
275
276
    /**
277
     * @param ChatPhoto $photo
278
     */
279
    public function setPhoto($photo)
280
    {
281
        $this->photo = $photo;
282
    }
283
284
    /**
285
     * @return string
286
     */
287
    public function getBio()
288
    {
289
        return $this->bio;
290
    }
291
292
    /**
293
     * @param string $bio
294
     */
295
    public function setBio($bio)
296
    {
297
        $this->bio = $bio;
298
    }
299
300
    /**
301
     * @return string
302
     */
303
    public function getDescription()
304
    {
305
        return $this->description;
306
    }
307
308
    /**
309
     * @param string $description
310
     */
311
    public function setDescription($description)
312
    {
313
        $this->description = $description;
314
    }
315
316
    /**
317
     * @return string
318
     */
319
    public function getInviteLink()
320
    {
321
        return $this->inviteLink;
322
    }
323
324
    /**
325
     * @param string $inviteLink
326
     */
327
    public function setInviteLink($inviteLink)
328
    {
329
        $this->inviteLink = $inviteLink;
330
    }
331
332
    /**
333
     * @return Message
334
     */
335
    public function getPinnedMessage()
336
    {
337
        return $this->pinnedMessage;
338
    }
339
340
    /**
341
     * @param Message $pinnedMessage
342
     */
343
    public function setPinnedMessage($pinnedMessage)
344
    {
345
        $this->pinnedMessage = $pinnedMessage;
346
    }
347
348
    /**
349
     * @return ChatPermissions
350
     */
351
    public function getPermissions()
352
    {
353
        return $this->permissions;
354
    }
355
356
    /**
357
     * @param ChatPermissions $permissions
358
     */
359
    public function setPermissions($permissions)
360
    {
361
        $this->permissions = $permissions;
362
    }
363
364
    /**
365
     * @return int
366
     */
367
    public function getSlowModeDelay()
368
    {
369
        return $this->slowModeDelay;
370
    }
371
372
    /**
373
     * @param int $slowModeDelay
374
     */
375
    public function setSlowModeDelay($slowModeDelay)
376
    {
377
        $this->slowModeDelay = $slowModeDelay;
378
    }
379
380
    /**
381
     * @return string
382
     */
383
    public function getStickerSetName()
384
    {
385
        return $this->stickerSetName;
386
    }
387
388
    /**
389
     * @param string $stickerSetName
390
     */
391
    public function setStickerSetName($stickerSetName)
392
    {
393
        $this->stickerSetName = $stickerSetName;
394
    }
395
396
    /**
397
     * @return bool
398
     */
399
    public function isCanSetStickerSet()
400
    {
401
        return $this->canSetStickerSet;
402
    }
403
404
    /**
405
     * @param bool $canSetStickerSet
406
     */
407
    public function setCanSetStickerSet($canSetStickerSet)
408
    {
409
        $this->canSetStickerSet = $canSetStickerSet;
410
    }
411
412
    /**
413
     * @return int
414
     */
415
    public function getLinkedChatId()
416
    {
417
        return $this->linkedChatId;
418
    }
419
420
    /**
421
     * @param int $linkedChatId
422
     */
423
    public function setLinkedChatId($linkedChatId)
424
    {
425
        $this->linkedChatId = $linkedChatId;
426
    }
427
428
    /**
429
     * @return ChatLocation
430
     */
431
    public function getLocation()
432
    {
433
        return $this->location;
434
    }
435
436
    /**
437
     * @param ChatLocation $location
438
     */
439
    public function setLocation($location)
440
    {
441
        $this->location = $location;
442
    }
443
}
444