Completed
Push — master ( 6a7f3a...a2dffe )
by
unknown
07:50
created

Message::setVoice()   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 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
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
use TelegramBot\Api\Types\Payments\Invoice;
8
use TelegramBot\Api\Types\Payments\SuccessfulPayment;
9
10
class Message extends BaseType implements TypeInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     *
15
     * @var array
16
     */
17
    static protected $requiredParams = ['message_id', 'date', 'chat'];
18
19
    /**
20
     * {@inheritdoc}
21
     *
22
     * @var array
23
     */
24
    static protected $map = [
25
        'message_id' => true,
26
        'from' => User::class,
27
        'date' => true,
28
        'chat' => Chat::class,
29
        'forward_from' => User::class,
30
        'forward_date' => true,
31
        'reply_to_message' => Message::class,
32
        'text' => true,
33
        'entities' => ArrayOfMessageEntity::class,
34
        'caption_entities' => ArrayOfMessageEntity::class,
35
        'audio' => Audio::class,
36
        'document' => Document::class,
37
        'photo' => ArrayOfPhotoSize::class,
38
        'sticker' => Sticker::class,
39
        'video' => Video::class,
40
        'voice' => Voice::class,
41
        'caption' => true,
42
        'contact' => Contact::class,
43
        'location' => Location::class,
44
        'venue' => Venue::class,
45
        'new_chat_member' => User::class,
46
        'left_chat_member' => User::class,
47
        'new_chat_title' => true,
48
        'new_chat_photo' => ArrayOfPhotoSize::class,
49
        'delete_chat_photo' => true,
50
        'group_chat_created' => true,
51
        'supergroup_chat_created' => true,
52
        'channel_chat_created' => true,
53
        'migrate_to_chat_id' => true,
54
        'migrate_from_chat_id' => true,
55
        'pinned_message' => Message::class,
56
        'invoice' => Invoice::class,
57
        'successful_payment' => SuccessfulPayment::class,
58
        'forward_signature' => true,
59
        'author_signature' => true
60
    ];
61
62
    /**
63
     * Unique message identifier
64
     *
65
     * @var int
66
     */
67
    protected $messageId;
68
69
    /**
70
     * Optional. Sender name. Can be empty for messages sent to channels
71
     *
72
     * @var \TelegramBot\Api\Types\User
73
     */
74
    protected $from;
75
76
    /**
77
     * Date the message was sent in Unix time
78
     *
79
     * @var int
80
     */
81
    protected $date;
82
83
    /**
84
     * Conversation the message belongs to — user in case of a private message, GroupChat in case of a group
85
     *
86
     * @var \TelegramBot\Api\Types\Chat
87
     */
88
    protected $chat;
89
90
    /**
91
     * Optional. For forwarded messages, sender of the original message
92
     *
93
     * @var \TelegramBot\Api\Types\User
94
     */
95
    protected $forwardFrom;
96
97
    /**
98
     * Optional. For forwarded messages, date the original message was sent in Unix time
99
     *
100
     * @var int
101
     */
102
    protected $forwardDate;
103
104
    /**
105
     * Optional. For replies, the original message. Note that the Message object in this field will not contain further
106
     * reply_to_message fields even if it itself is a reply.
107
     *
108
     * @var \TelegramBot\Api\Types\Message
109
     */
110
    protected $replyToMessage;
111
112
    /**
113
     * Optional. For text messages, the actual UTF-8 text of the message
114
     *
115
     * @var string
116
     */
117
    protected $text;
118
119
    /**
120
     * Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text.
121
     * array of \TelegramBot\Api\Types\MessageEntity
122
     *
123
     * @var array
124
     */
125
    protected $entities;
126
127
    /**
128
     * Optional. Message is an audio file, information about the file
129
     *
130
     * @var \TelegramBot\Api\Types\Audio
131
     */
132
    protected $audio;
133
134
    /**
135
     * Optional. Message is a general file, information about the file
136
     *
137
     * @var \TelegramBot\Api\Types\Document
138
     */
139
    protected $document;
140
141
    /**
142
     * Optional. Message is a photo, available sizes of the photo
143
     * array of \TelegramBot\Api\Types\Photo
144
     *
145
     * @var array
146
     */
147
    protected $photo;
148
149
    /**
150
     * Optional. Message is a sticker, information about the sticker
151
     *
152
     * @var \TelegramBot\Api\Types\Sticker
153
     */
154
    protected $sticker;
155
156
    /**
157
     * Optional. Message is a video, information about the video
158
     *
159
     * @var \TelegramBot\Api\Types\Video
160
     */
161
    protected $video;
162
163
    /**
164
     * Optional. Message is a voice message, information about the file
165
     *
166
     * @var \TelegramBot\Api\Types\Voice
167
     */
168
    protected $voice;
169
170
    /**
171
     * Optional. Message is a shared contact, information about the contact
172
     *
173
     * @var \TelegramBot\Api\Types\Contact
174
     */
175
    protected $contact;
176
177
    /**
178
     * Optional. Message is a shared location, information about the location
179
     *
180
     * @var \TelegramBot\Api\Types\Location
181
     */
182
    protected $location;
183
184
    /**
185
     * Optional. Message is a venue, information about the venue
186
     *
187
     * @var \TelegramBot\Api\Types\Venue
188
     */
189
    protected $venue;
190
191
    /**
192
     * Optional. A new member was added to the group, information about them (this member may be bot itself)
193
     *
194
     * @var \TelegramBot\Api\Types\User
195
     */
196
    protected $newChatMember;
197
198
    /**
199
     * Optional. A member was removed from the group, information about them (this member may be bot itself)
200
     *
201
     * @var \TelegramBot\Api\Types\User
202
     */
203
    protected $leftChatMember;
204
205
    /**
206
     * Optional. A group title was changed to this value
207
     *
208
     * @var string
209
     */
210
    protected $newChatTitle;
211
212
    /**
213
     * Optional. A group photo was change to this value
214
     *
215
     * @var mixed
216
     */
217
    protected $newChatPhoto;
218
219
    /**
220
     * Optional. Informs that the group photo was deleted
221
     *
222
     * @var bool
223
     */
224
    protected $deleteChatPhoto;
225
226
    /**
227
     * Optional. Informs that the group has been created
228
     *
229
     * @var bool
230
     */
231
    protected $groupChatCreated;
232
233
    /**
234
     * Optional. Text description of the video (usually empty)
235
     *
236
     * @var string
237
     */
238
    protected $caption;
239
240
241
    /**
242
     * Optional. Service message: the supergroup has been created
243
     *
244
     * @var bool
245
     */
246
    protected $supergroupChatCreated;
247
248
    /**
249
     * Optional. Service message: the channel has been created
250
     *
251
     * @var bool
252
     */
253
    protected $channelChatCreated;
254
255
    /**
256
     * Optional. The group has been migrated to a supergroup with the specified identifier,
257
     * not exceeding 1e13 by absolute value
258
     *
259
     * @var int
260
     */
261
    protected $migrateToChatId;
262
263
    /**
264
     * Optional. The supergroup has been migrated from a group with the specified identifier,
265
     * not exceeding 1e13 by absolute value
266
     *
267
     * @var int
268
     */
269
    protected $migrateFromChatId;
270
271
    /**
272
     * Optional. Specified message was pinned.Note that the Message object in this field
273
     * will not contain further reply_to_message fields even if it is itself a reply.
274
     *
275
     * @var Message
276
     */
277
    protected $pinnedMessage;
278
279
    /**
280
     * Optional. Message is an invoice for a payment, information about the invoice.
281
     *
282
     * @var Invoice
283
     */
284
    protected $invoice;
285
286
    /**
287
     * Optional. Message is a service message about a successful payment, information about the payment.
288
     *
289
     * @var SuccessfulPayment
290
     */
291
    protected $successfulPayment;
292
293
    /**
294
     * Optional. For messages forwarded from channels, signature of the post author if present
295
     *
296
     * @var string
297
     */
298
    protected $forwardSignature;
299
300
    /**
301
     * Optional. Signature of the post author for messages in channels
302
     *
303
     * @var string
304
     */
305
    protected $authorSignature;
306
307
    /**
308
     * Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
309
     *
310
     * @var ArrayOfMessageEntity
311
     */
312
    protected $captionEntities;
313
314
    /**
315
     * @return string
316
     */
317 1
    public function getCaption()
318
    {
319 1
        return $this->caption;
320
    }
321
322
    /**
323
     * @param string $caption
324
     */
325 2
    public function setCaption($caption)
326
    {
327 2
        $this->caption = $caption;
328 2
    }
329
330
    /**
331
     * @return Audio
332
     */
333 1
    public function getAudio()
334
    {
335 1
        return $this->audio;
336
    }
337
338
    /**
339
     * @param Audio $audio
340
     */
341 2
    public function setAudio(Audio $audio)
342
    {
343 2
        $this->audio = $audio;
344 2
    }
345
346
    /**
347
     * @return Chat
348
     */
349 2
    public function getChat()
350
    {
351 2
        return $this->chat;
352
    }
353
354
    /**
355
     * @param Chat $chat
356
     */
357 15
    public function setChat(Chat $chat)
358
    {
359 15
        $this->chat = $chat;
360 15
    }
361
362
    /**
363
     * @return Contact
364
     */
365 1
    public function getContact()
366
    {
367 1
        return $this->contact;
368
    }
369
370
    /**
371
     * @param Contact $contact
372
     */
373 2
    public function setContact(Contact $contact)
374
    {
375 2
        $this->contact = $contact;
376 2
    }
377
378
    /**
379
     * @return int
380
     */
381 1
    public function getDate()
382
    {
383 1
        return $this->date;
384
    }
385
386
    /**
387
     * @param int $date
388
     *
389
     * @throws InvalidArgumentException
390
     */
391 14
    public function setDate($date)
392
    {
393 14
        if (is_integer($date)) {
394 13
            $this->date = $date;
395 13
        } else {
396 1
            throw new InvalidArgumentException();
397
        }
398 13
    }
399
400
    /**
401
     * @return boolean
402
     */
403 1
    public function isDeleteChatPhoto()
404
    {
405 1
        return $this->deleteChatPhoto;
406
    }
407
408
    /**
409
     * @param boolean $deleteChatPhoto
410
     */
411 2
    public function setDeleteChatPhoto($deleteChatPhoto)
412
    {
413 2
        $this->deleteChatPhoto = (bool)$deleteChatPhoto;
414 2
    }
415
416
    /**
417
     * @return Document
418
     */
419 1
    public function getDocument()
420
    {
421 1
        return $this->document;
422
    }
423
424
    /**
425
     * @param Document $document
426
     */
427 2
    public function setDocument($document)
428
    {
429 2
        $this->document = $document;
430 2
    }
431
432
    /**
433
     * @return int
434
     */
435 1
    public function getForwardDate()
436
    {
437 1
        return $this->forwardDate;
438
    }
439
440
    /**
441
     * @param int $forwardDate
442
     *
443
     * @throws InvalidArgumentException
444
     */
445 3
    public function setForwardDate($forwardDate)
446
    {
447 3
        if (is_integer($forwardDate)) {
448 2
            $this->forwardDate = $forwardDate;
449 2
        } else {
450 1
            throw new InvalidArgumentException();
451
        }
452 2
    }
453
454
    /**
455
     * @return User
456
     */
457 1
    public function getForwardFrom()
458
    {
459 1
        return $this->forwardFrom;
460
    }
461
462
    /**
463
     * @param User $forwardFrom
464
     */
465 2
    public function setForwardFrom(User $forwardFrom)
466
    {
467 2
        $this->forwardFrom = $forwardFrom;
468 2
    }
469
470
    /**
471
     * @return boolean
472
     */
473 1
    public function isGroupChatCreated()
474
    {
475 1
        return $this->groupChatCreated;
476
    }
477
478
    /**
479
     * @param boolean $groupChatCreated
480
     */
481 2
    public function setGroupChatCreated($groupChatCreated)
482
    {
483 2
        $this->groupChatCreated = (bool)$groupChatCreated;
484 2
    }
485
486
    /**
487
     * @return User
488
     */
489 1
    public function getLeftChatMember()
490
    {
491 1
        return $this->leftChatMember;
492
    }
493
494
    /**
495
     * @param User $leftChatMember
496
     */
497 2
    public function setLeftChatMember($leftChatMember)
498
    {
499 2
        $this->leftChatMember = $leftChatMember;
500 2
    }
501
502
    /**
503
     * @return Location
504
     */
505 1
    public function getLocation()
506
    {
507 1
        return $this->location;
508
    }
509
510
    /**
511
     * @param Location $location
512
     */
513 2
    public function setLocation(Location $location)
514
    {
515 2
        $this->location = $location;
516 2
    }
517
518
    /**
519
     * @return Venue
520
     */
521
    public function getVenue()
522
    {
523
        return $this->venue;
524
    }
525
526
    /**
527
     * @param Venue $venue
528
     */
529
    public function setVenue($venue)
530
    {
531
        $this->venue = $venue;
532
    }
533
534
    /**
535
     * @return int
536
     */
537 1
    public function getMessageId()
538
    {
539 1
        return $this->messageId;
540
    }
541
542
    /**
543
     * @param int $messageId
544
     *
545
     * @throws InvalidArgumentException
546
     */
547 15
    public function setMessageId($messageId)
548
    {
549 15
        if (is_integer($messageId) || is_float($messageId)) {
550 14
            $this->messageId = $messageId;
0 ignored issues
show
Documentation Bug introduced by
It seems like $messageId can also be of type double. However, the property $messageId is declared as type integer. 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...
551 14
        } else {
552 1
            throw new InvalidArgumentException();
553
        }
554 14
    }
555
556
    /**
557
     * @return User
558
     */
559 1
    public function getNewChatMember()
560
    {
561 1
        return $this->newChatMember;
562
    }
563
564
    /**
565
     * @param User $newChatMember
566
     */
567 2
    public function setNewChatMember($newChatMember)
568
    {
569 2
        $this->newChatMember = $newChatMember;
570 2
    }
571
572
    /**
573
     * @return array
574
     */
575 1
    public function getNewChatPhoto()
576
    {
577 1
        return $this->newChatPhoto;
578
    }
579
580
    /**
581
     * @param array $newChatPhoto
582
     */
583 2
    public function setNewChatPhoto($newChatPhoto)
584
    {
585 2
        $this->newChatPhoto = $newChatPhoto;
586 2
    }
587
588
    /**
589
     * @return string
590
     */
591 1
    public function getNewChatTitle()
592
    {
593 1
        return $this->newChatTitle;
594
    }
595
596
    /**
597
     * @param string $newChatTitle
598
     */
599 2
    public function setNewChatTitle($newChatTitle)
600
    {
601 2
        $this->newChatTitle = $newChatTitle;
602 2
    }
603
604
    /**
605
     * @return array
606
     */
607 1
    public function getPhoto()
608
    {
609 1
        return $this->photo;
610
    }
611
612
    /**
613
     * @param array $photo
614
     */
615 2
    public function setPhoto(array $photo)
616
    {
617 2
        $this->photo = $photo;
618 2
    }
619
620
    /**
621
     * @return Message
622
     */
623 1
    public function getReplyToMessage()
624
    {
625 1
        return $this->replyToMessage;
626
    }
627
628
    /**
629
     * @param Message $replyToMessage
630
     */
631 2
    public function setReplyToMessage(Message $replyToMessage)
632
    {
633 2
        $this->replyToMessage = $replyToMessage;
634 2
    }
635
636
    /**
637
     * @return Sticker
638
     */
639 1
    public function getSticker()
640
    {
641 1
        return $this->sticker;
642
    }
643
644
    /**
645
     * @param Sticker $sticker
646
     */
647 2
    public function setSticker(Sticker $sticker)
648
    {
649 2
        $this->sticker = $sticker;
650 2
    }
651
652
    /**
653
     * @return string
654
     */
655 7
    public function getText()
656
    {
657 7
        return $this->text;
658
    }
659
660
    /**
661
     * @param string $text
662
     */
663 5
    public function setText($text)
664
    {
665 5
        $this->text = $text;
666 5
    }
667
668
    /**
669
     * @return array
670
     */
671
    public function getEntities()
672
    {
673
        return $this->entities;
674
    }
675
676
    /**
677
     * @param array $entities
678
     */
679 1
    public function setEntities($entities)
680
    {
681 1
        $this->entities = $entities;
682 1
    }
683
684
    /**
685
     * @return User
686
     */
687 1
    public function getFrom()
688
    {
689 1
        return $this->from;
690
    }
691
692
    /**
693
     * @param User $from
694
     */
695 13
    public function setFrom(User $from)
696
    {
697 13
        $this->from = $from;
698 13
    }
699
700
    /**
701
     * @return Video
702
     */
703 1
    public function getVideo()
704
    {
705 1
        return $this->video;
706
    }
707
708
    /**
709
     * @param Video $video
710
     */
711 2
    public function setVideo(Video $video)
712
    {
713 2
        $this->video = $video;
714 2
    }
715
716
    /**
717
     * @return Voice
718
     */
719 1
    public function getVoice()
720
    {
721 1
        return $this->voice;
722
    }
723
724
    /**
725
     * @param Voice $voice
726
     */
727 2
    public function setVoice($voice)
728
    {
729 2
        $this->voice = $voice;
730 2
    }
731
732
    /**
733
     * @param boolean $supergroupChatCreated
734
     */
735 2
    public function setSupergroupChatCreated($supergroupChatCreated)
736
    {
737 2
        $this->supergroupChatCreated = $supergroupChatCreated;
738 2
    }
739
740
    /**
741
     * @return boolean
742
     */
743 1
    public function isSupergroupChatCreated()
744
    {
745 1
        return $this->supergroupChatCreated;
746
    }
747
748
    /**
749
     * @param boolean $channelChatCreated
750
     */
751 2
    public function setChannelChatCreated($channelChatCreated)
752
    {
753 2
        $this->channelChatCreated = $channelChatCreated;
754 2
    }
755
756
    /**
757
     * @return boolean
758
     */
759 1
    public function isChannelChatCreated()
760
    {
761 1
        return $this->channelChatCreated;
762
    }
763
764
    /**
765
     * @param int $migrateToChatId
766
     */
767 2
    public function setMigrateToChatId($migrateToChatId)
768
    {
769 2
        $this->migrateToChatId = $migrateToChatId;
770 2
    }
771
772
    /**
773
     * @return int
774
     */
775 1
    public function getMigrateToChatId()
776
    {
777 1
        return $this->migrateToChatId;
778
    }
779
780
    /**
781
     * @param int $migrateFromChatId
782
     */
783 4
    public function setMigrateFromChatId($migrateFromChatId)
784
    {
785 4
        $this->migrateFromChatId = $migrateFromChatId;
786 4
    }
787
788
    /**
789
     * @return int
790
     */
791 1
    public function getMigrateFromChatId()
792
    {
793 1
        return $this->migrateFromChatId;
794
    }
795
796
    /**
797
     * @return Message
798
     */
799
    public function getPinnedMessage()
800
    {
801
        return $this->pinnedMessage;
802
    }
803
804
    /**
805
     * @param Message $pinnedMessage
806
     */
807
    public function setPinnedMessage($pinnedMessage)
808
    {
809
        $this->pinnedMessage = $pinnedMessage;
810
    }
811
812
    /**
813
     * @author MY
814
     * @return Invoice
815
     */
816
    public function getInvoice()
817
    {
818
        return $this->invoice;
819
    }
820
821
    /**
822
     * @author MY
823
     * @param Invoice $invoice
824
     */
825
    public function setInvoice($invoice)
826
    {
827
        $this->invoice = $invoice;
828
    }
829
830
    /**
831
     * @author MY
832
     * @return SuccessfulPayment
833
     */
834
    public function getSuccessfulPayment()
835
    {
836
        return $this->successfulPayment;
837
    }
838
839
    /**
840
     * @author MY
841
     * @param SuccessfulPayment $successfulPayment
842
     */
843
    public function setSuccessfulPayment($successfulPayment)
844
    {
845
        $this->successfulPayment = $successfulPayment;
846
    }
847
848
    /**
849
     * @return string
850
     */
851
    public function getForwardSignature()
852
    {
853
        return $this->forwardSignature;
854
    }
855
856
    /**
857
     * @param string $forwardSignature
858
     */
859
    public function setForwardSignature($forwardSignature)
860
    {
861
        $this->forwardSignature = $forwardSignature;
862
    }
863
864
    /**
865
     * @return string
866
     */
867
    public function getAuthorSignature()
868
    {
869
        return $this->authorSignature;
870
    }
871
872
    /**
873
     * @param string $authorSignature
874
     */
875
    public function setAuthorSignature($authorSignature)
876
    {
877
        $this->authorSignature = $authorSignature;
878
    }
879
880
    /**
881
     * @return ArrayOfMessageEntity
882
     */
883
    public function getCaptionEntities()
884
    {
885
        return $this->captionEntities;
886
    }
887
888
    /**
889
     * @param ArrayOfMessageEntity $captionEntities
890
     */
891
    public function setCaptionEntities($captionEntities)
892
    {
893
        $this->captionEntities = $captionEntities;
894
    }
895
}
896