Completed
Push — master ( 91dadc...25bb18 )
by Gusev
02:46
created

Message::setEntities()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
namespace TelegramBot\Api\Types;
3
4
use TelegramBot\Api\BaseType;
5
use TelegramBot\Api\InvalidArgumentException;
6
use TelegramBot\Api\TypeInterface;
7
8
class Message extends BaseType implements TypeInterface
9
{
10
    /**
11
     * {@inheritdoc}
12
     *
13
     * @var array
14
     */
15
    static protected $requiredParams = ['message_id', 'date', 'chat'];
16
17
    /**
18
     * {@inheritdoc}
19
     *
20
     * @var array
21
     */
22
    static protected $map = [
23
        'message_id' => true,
24
        'from' => User::class,
25
        'date' => true,
26
        'chat' => Chat::class,
27
        'forward_from' => User::class,
28
        'forward_date' => true,
29
        'reply_to_message' => Message::class,
30
        'text' => true,
31
        'entities' => ArrayOfMessageEntity::class,
32
        'audio' => Audio::class,
33
        'document' => Document::class,
34
        'photo' => ArrayOfPhotoSize::class,
35
        'sticker' => Sticker::class,
36
        'video' => Video::class,
37
        'voice' => Voice::class,
38
        'caption' => true,
39
        'contact' => Contact::class,
40
        'location' => Location::class,
41
        'new_chat_member' => User::class,
42
        'left_chat_member' => User::class,
43
        'new_chat_title' => true,
44
        'new_chat_photo' => ArrayOfPhotoSize::class,
45
        'delete_chat_photo' => true,
46
        'group_chat_created' => true,
47
        'supergroup_chat_created' => true,
48
        'channel_chat_created' => true,
49
        'migrate_to_chat_id' => true,
50
        'migrate_from_chat_id' => true,
51
    ];
52
53
    /**
54
     * Unique message identifier
55
     *
56
     * @var int
57
     */
58
    protected $messageId;
59
60
    /**
61
     * Optional. Sender name. Can be empty for messages sent to channels
62
     *
63
     * @var \TelegramBot\Api\Types\User
64
     */
65
    protected $from;
66
67
    /**
68
     * Date the message was sent in Unix time
69
     *
70
     * @var int
71
     */
72
    protected $date;
73
74
    /**
75
     * Conversation the message belongs to — user in case of a private message, GroupChat in case of a group
76
     *
77
     * @var \TelegramBot\Api\Types\Chat
78
     */
79
    protected $chat;
80
81
    /**
82
     * Optional. For forwarded messages, sender of the original message
83
     *
84
     * @var \TelegramBot\Api\Types\User
85
     */
86
    protected $forwardFrom;
87
88
    /**
89
     * Optional. For forwarded messages, date the original message was sent in Unix time
90
     *
91
     * @var int
92
     */
93
    protected $forwardDate;
94
95
    /**
96
     * Optional. For replies, the original message. Note that the Message object in this field will not contain further
97
     * reply_to_message fields even if it itself is a reply.
98
     *
99
     * @var \TelegramBot\Api\Types\Message
100
     */
101
    protected $replyToMessage;
102
103
    /**
104
     * Optional. For text messages, the actual UTF-8 text of the message
105
     *
106
     * @var string
107
     */
108
    protected $text;
109
110
    /**
111
     * Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text.
112
     * array of \TelegramBot\Api\Types\MessageEntity
113
     *
114
     * @var array
115
     */
116
    protected $entities;
117
118
    /**
119
     * Optional. Message is an audio file, information about the file
120
     *
121
     * @var \TelegramBot\Api\Types\Audio
122
     */
123
    protected $audio;
124
125
    /**
126
     * Optional. Message is a general file, information about the file
127
     *
128
     * @var \TelegramBot\Api\Types\Document
129
     */
130
    protected $document;
131
132
    /**
133
     * Optional. Message is a photo, available sizes of the photo
134
     * array of \TelegramBot\Api\Types\Photo
135
     *
136
     * @var array
137
     */
138
    protected $photo;
139
140
    /**
141
     * Optional. Message is a sticker, information about the sticker
142
     *
143
     * @var \TelegramBot\Api\Types\Sticker
144
     */
145
    protected $sticker;
146
147
    /**
148
     * Optional. Message is a video, information about the video
149
     *
150
     * @var \TelegramBot\Api\Types\Video
151
     */
152
    protected $video;
153
154
    /**
155
     * Optional. Message is a voice message, information about the file
156
     *
157
     * @var \TelegramBot\Api\Types\Voice
158
     */
159
    protected $voice;
160
161
    /**
162
     * Optional. Message is a shared contact, information about the contact
163
     *
164
     * @var \TelegramBot\Api\Types\Contact
165
     */
166
    protected $contact;
167
168
    /**
169
     * Optional. Message is a shared location, information about the location
170
     *
171
     * @var \TelegramBot\Api\Types\Location
172
     */
173
    protected $location;
174
175
    /**
176
     * Optional. A new member was added to the group, information about them (this member may be bot itself)
177
     *
178
     * @var \TelegramBot\Api\Types\User
179
     */
180
    protected $newChatMember;
181
182
    /**
183
     * Optional. A member was removed from the group, information about them (this member may be bot itself)
184
     *
185
     * @var \TelegramBot\Api\Types\User
186
     */
187
    protected $leftChatMember;
188
189
    /**
190
     * Optional. A group title was changed to this value
191
     *
192
     * @var string
193
     */
194
    protected $newChatTitle;
195
196
    /**
197
     * Optional. A group photo was change to this value
198
     *
199
     * @var mixed
200
     */
201
    protected $newChatPhoto;
202
203
    /**
204
     * Optional. Informs that the group photo was deleted
205
     *
206
     * @var bool
207
     */
208
    protected $deleteChatPhoto;
209
210
    /**
211
     * Optional. Informs that the group has been created
212
     *
213
     * @var bool
214
     */
215
    protected $groupChatCreated;
216
217
    /**
218
     * Optional. Text description of the video (usually empty)
219
     *
220
     * @var string
221
     */
222
    protected $caption;
223
224
225
    /**
226
     * Optional. Service message: the supergroup has been created
227
     *
228
     * @var bool
229
     */
230
    protected $supergroupChatCreated;
231
232
    /**
233
     * Optional. Service message: the channel has been created
234
     *
235
     * @var bool
236
     */
237
    protected $channelChatCreated;
238
239
    /**
240
     * Optional. The group has been migrated to a supergroup with the specified identifier,
241
     * not exceeding 1e13 by absolute value
242
     *
243
     * @var int
244
     */
245
    protected $migrateToChatId;
246
247
    /**
248
     * Optional. The supergroup has been migrated from a group with the specified identifier,
249
     * not exceeding 1e13 by absolute value
250
     *
251
     * @var int
252
     */
253
    protected $migrateFromChatId;
254
255
    /**
256
     * @return string
257
     */
258 1
    public function getCaption()
259
    {
260 1
        return $this->caption;
261
    }
262
263
    /**
264
     * @param string $caption
265
     */
266 2
    public function setCaption($caption)
267
    {
268 2
        $this->caption = $caption;
269 2
    }
270
271
    /**
272
     * @return Audio
273
     */
274 1
    public function getAudio()
275
    {
276 1
        return $this->audio;
277
    }
278
279
    /**
280
     * @param Audio $audio
281
     */
282 2
    public function setAudio(Audio $audio)
283
    {
284 2
        $this->audio = $audio;
285 2
    }
286
287
    /**
288
     * @return TypeInterface
289
     */
290 2
    public function getChat()
291
    {
292 2
        return $this->chat;
293
    }
294
295
    /**
296
     * @param Chat $chat
297
     */
298 13
    public function setChat(Chat $chat)
299
    {
300 13
        $this->chat = $chat;
301 13
    }
302
303
    /**
304
     * @return Contact
305
     */
306 1
    public function getContact()
307
    {
308 1
        return $this->contact;
309
    }
310
311
    /**
312
     * @param Contact $contact
313
     */
314 2
    public function setContact(Contact $contact)
315
    {
316 2
        $this->contact = $contact;
317 2
    }
318
319
    /**
320
     * @return int
321
     */
322 1
    public function getDate()
323
    {
324 1
        return $this->date;
325
    }
326
327
    /**
328
     * @param int $date
329
     *
330
     * @throws InvalidArgumentException
331
     */
332 12
    public function setDate($date)
333
    {
334 12
        if (is_integer($date)) {
335 11
            $this->date = $date;
336 11
        } else {
337 1
            throw new InvalidArgumentException();
338
        }
339 11
    }
340
341
    /**
342
     * @return boolean
343
     */
344 1
    public function isDeleteChatPhoto()
345
    {
346 1
        return $this->deleteChatPhoto;
347
    }
348
349
    /**
350
     * @param boolean $deleteChatPhoto
351
     */
352 2
    public function setDeleteChatPhoto($deleteChatPhoto)
353
    {
354 2
        $this->deleteChatPhoto = (bool)$deleteChatPhoto;
355 2
    }
356
357
    /**
358
     * @return Document
359
     */
360 1
    public function getDocument()
361
    {
362 1
        return $this->document;
363
    }
364
365
    /**
366
     * @param Document $document
367
     */
368 2
    public function setDocument($document)
369
    {
370 2
        $this->document = $document;
371 2
    }
372
373
    /**
374
     * @return int
375
     */
376 1
    public function getForwardDate()
377
    {
378 1
        return $this->forwardDate;
379
    }
380
381
    /**
382
     * @param int $forwardDate
383
     *
384
     * @throws InvalidArgumentException
385
     */
386 3
    public function setForwardDate($forwardDate)
387
    {
388 3
        if (is_integer($forwardDate)) {
389 2
            $this->forwardDate = $forwardDate;
390 2
        } else {
391 1
            throw new InvalidArgumentException();
392
        }
393 2
    }
394
395
    /**
396
     * @return User
397
     */
398 1
    public function getForwardFrom()
399
    {
400 1
        return $this->forwardFrom;
401
    }
402
403
    /**
404
     * @param User $forwardFrom
405
     */
406 2
    public function setForwardFrom(User $forwardFrom)
407
    {
408 2
        $this->forwardFrom = $forwardFrom;
409 2
    }
410
411
    /**
412
     * @return boolean
413
     */
414 1
    public function isGroupChatCreated()
415
    {
416 1
        return $this->groupChatCreated;
417
    }
418
419
    /**
420
     * @param boolean $groupChatCreated
421
     */
422 2
    public function setGroupChatCreated($groupChatCreated)
423
    {
424 2
        $this->groupChatCreated = (bool)$groupChatCreated;
425 2
    }
426
427
    /**
428
     * @return User
429
     */
430 1
    public function getLeftChatMember()
431
    {
432 1
        return $this->leftChatMember;
433
    }
434
435
    /**
436
     * @param User $leftChatMember
437
     */
438 2
    public function setLeftChatMember($leftChatMember)
439
    {
440 2
        $this->leftChatMember = $leftChatMember;
441 2
    }
442
443
    /**
444
     * @return Location
445
     */
446 1
    public function getLocation()
447
    {
448 1
        return $this->location;
449
    }
450
451
    /**
452
     * @param Location $location
453
     */
454 2
    public function setLocation(Location $location)
455
    {
456 2
        $this->location = $location;
457 2
    }
458
459
    /**
460
     * @return int
461
     */
462 1
    public function getMessageId()
463
    {
464 1
        return $this->messageId;
465
    }
466
467
    /**
468
     * @param int $messageId
469
     *
470
     * @throws InvalidArgumentException
471
     */
472 12
    public function setMessageId($messageId)
473
    {
474 12
        if (is_integer($messageId)) {
475 11
            $this->messageId = $messageId;
476 11
        } else {
477 1
            throw new InvalidArgumentException();
478
        }
479 11
    }
480
481
    /**
482
     * @return User
483
     */
484 1
    public function getNewChatMember()
485
    {
486 1
        return $this->newChatMember;
487
    }
488
489
    /**
490
     * @param User $newChatMember
491
     */
492 2
    public function setNewChatMember($newChatMember)
493
    {
494 2
        $this->newChatMember = $newChatMember;
495 2
    }
496
497
    /**
498
     * @return array
499
     */
500 1
    public function getNewChatPhoto()
501
    {
502 1
        return $this->newChatPhoto;
503
    }
504
505
    /**
506
     * @param array $newChatPhoto
507
     */
508 2
    public function setNewChatPhoto($newChatPhoto)
509
    {
510 2
        $this->newChatPhoto = $newChatPhoto;
511 2
    }
512
513
    /**
514
     * @return string
515
     */
516 1
    public function getNewChatTitle()
517
    {
518 1
        return $this->newChatTitle;
519
    }
520
521
    /**
522
     * @param string $newChatTitle
523
     */
524 2
    public function setNewChatTitle($newChatTitle)
525
    {
526 2
        $this->newChatTitle = $newChatTitle;
527 2
    }
528
529
    /**
530
     * @return array
531
     */
532 1
    public function getPhoto()
533
    {
534 1
        return $this->photo;
535
    }
536
537
    /**
538
     * @param array $photo
539
     */
540 2
    public function setPhoto(array $photo)
541
    {
542 2
        $this->photo = $photo;
543 2
    }
544
545
    /**
546
     * @return Message
547
     */
548 1
    public function getReplyToMessage()
549
    {
550 1
        return $this->replyToMessage;
551
    }
552
553
    /**
554
     * @param Message $replyToMessage
555
     */
556 2
    public function setReplyToMessage(Message $replyToMessage)
557
    {
558 2
        $this->replyToMessage = $replyToMessage;
559 2
    }
560
561
    /**
562
     * @return Sticker
563
     */
564 1
    public function getSticker()
565
    {
566 1
        return $this->sticker;
567
    }
568
569
    /**
570
     * @param Sticker $sticker
571
     */
572 2
    public function setSticker(Sticker $sticker)
573
    {
574 2
        $this->sticker = $sticker;
575 2
    }
576
577
    /**
578
     * @return string
579
     */
580 7
    public function getText()
581
    {
582 7
        return $this->text;
583
    }
584
585
    /**
586
     * @param string $text
587
     */
588 5
    public function setText($text)
589
    {
590 5
        $this->text = $text;
591 5
    }
592
593
    /**
594
     * @return array
595
     */
596
    public function getEntities()
597
    {
598
        return $this->entities;
599
    }
600
601
    /**
602
     * @param array $entities
603
     */
604
    public function setEntities($entities)
605
    {
606
        $this->entities = $entities;
607
    }
608
609
    /**
610
     * @return User
611
     */
612 1
    public function getFrom()
613
    {
614 1
        return $this->from;
615
    }
616
617
    /**
618
     * @param User $from
619
     */
620 11
    public function setFrom(User $from)
621
    {
622 11
        $this->from = $from;
623 11
    }
624
625
    /**
626
     * @return Video
627
     */
628 1
    public function getVideo()
629
    {
630 1
        return $this->video;
631
    }
632
633
    /**
634
     * @param Video $video
635
     */
636 2
    public function setVideo(Video $video)
637
    {
638 2
        $this->video = $video;
639 2
    }
640
641
    /**
642
     * @return Voice
643
     */
644 1
    public function getVoice()
645
    {
646 1
        return $this->voice;
647
    }
648
649
    /**
650
     * @param Voice $voice
651
     */
652 2
    public function setVoice($voice)
653
    {
654 2
        $this->voice = $voice;
655 2
    }
656
657
    /**
658
     * @param boolean $supergroupChatCreated
659
     */
660 2
    public function setSupergroupChatCreated($supergroupChatCreated)
661
    {
662 2
        $this->supergroupChatCreated = $supergroupChatCreated;
663 2
    }
664
665
    /**
666
     * @return boolean
667
     */
668 1
    public function isSupergroupChatCreated()
669
    {
670 1
        return $this->supergroupChatCreated;
671
    }
672
673
    /**
674
     * @param boolean $channelChatCreated
675
     */
676 2
    public function setChannelChatCreated($channelChatCreated)
677
    {
678 2
        $this->channelChatCreated = $channelChatCreated;
679 2
    }
680
681
    /**
682
     * @return boolean
683
     */
684 1
    public function isChannelChatCreated()
685
    {
686 1
        return $this->channelChatCreated;
687
    }
688
689
    /**
690
     * @param int $migrateToChatId
691
     */
692 2
    public function setMigrateToChatId($migrateToChatId)
693
    {
694 2
        $this->migrateToChatId = $migrateToChatId;
695 2
    }
696
697
    /**
698
     * @return int
699
     */
700 1
    public function getMigrateToChatId()
701
    {
702 1
        return $this->migrateToChatId;
703
    }
704
705
    /**
706
     * @param int $migrateFromChatId
707
     */
708 2
    public function setMigrateFromChatId($migrateFromChatId)
709
    {
710 2
        $this->migrateFromChatId = $migrateFromChatId;
711 2
    }
712
713
    /**
714
     * @return int
715
     */
716 1
    public function getMigrateFromChatId()
717
    {
718 1
        return $this->migrateFromChatId;
719
    }
720
}
721