Completed
Push — master ( 25bb18...6c3ef1 )
by Gusev
05:17 queued 02:29
created

Message::setGroupChatCreated()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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