Passed
Pull Request — master (#187)
by
unknown
03:27
created

Message::setVenue()   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 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
use TelegramBot\Api\Types\Payments\Invoice;
9
use TelegramBot\Api\Types\Payments\SuccessfulPayment;
10
11
class Message extends BaseType implements TypeInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     *
16
     * @var array
17
     */
18
    static protected $requiredParams = ['message_id', 'date', 'chat'];
19
20
    /**
21
     * {@inheritdoc}
22
     *
23
     * @var array
24
     */
25
    static protected $map = [
26
        'message_id' => TRUE,
27
        'from' => User::class,
28
        'date' => TRUE,
29
        'chat' => Chat::class,
30
        'forward_from' => User::class,
31
        'forward_date' => TRUE,
32
        'reply_to_message' => Message::class,
33
        'text' => TRUE,
34
        'entities' => ArrayOfMessageEntity::class,
35
        'caption_entities' => ArrayOfMessageEntity::class,
36
        'audio' => Audio::class,
37
        'document' => Document::class,
38
        'photo' => ArrayOfPhotoSize::class,
39
        'sticker' => Sticker::class,
40
        'video' => Video::class,
41
        'voice' => Voice::class,
42
        'caption' => TRUE,
43
        'contact' => Contact::class,
44
        'location' => Location::class,
45
        'venue' => Venue::class,
46
        'new_chat_member' => User::class,
47
        'new_chat_members' => ArrayOfUsers::class,
48
        'left_chat_member' => User::class,
49
        'new_chat_title' => TRUE,
50
        'new_chat_photo' => ArrayOfPhotoSize::class,
51
        'delete_chat_photo' => TRUE,
52
        'group_chat_created' => TRUE,
53
        'supergroup_chat_created' => TRUE,
54
        'channel_chat_created' => TRUE,
55
        'migrate_to_chat_id' => TRUE,
56
        'migrate_from_chat_id' => TRUE,
57
        'pinned_message' => Message::class,
58
        'invoice' => Invoice::class,
59
        'successful_payment' => SuccessfulPayment::class,
60
        'forward_signature' => TRUE,
61
        'author_signature' => TRUE,
62
        'connected_website' => TRUE
63
    ];
64
65
    /**
66
     * Unique message identifier
67
     *
68
     * @var int
69
     */
70
    protected $messageId;
71
72
    /**
73
     * Optional. Sender name. Can be empty for messages sent to channels
74
     *
75
     * @var \TelegramBot\Api\Types\User
76
     */
77
    protected $from;
78
79
    /**
80
     * Date the message was sent in Unix time
81
     *
82
     * @var int
83
     */
84
    protected $date;
85
86
    /**
87
     * Conversation the message belongs to — user in case of a private message, GroupChat in case of a group
88
     *
89
     * @var \TelegramBot\Api\Types\Chat
90
     */
91
    protected $chat;
92
93
    /**
94
     * Optional. For forwarded messages, sender of the original message
95
     *
96
     * @var \TelegramBot\Api\Types\User
97
     */
98
    protected $forwardFrom;
99
100
    /**
101
     * Optional. For forwarded messages, date the original message was sent in Unix time
102
     *
103
     * @var int
104
     */
105
    protected $forwardDate;
106
107
    /**
108
     * Optional. For replies, the original message. Note that the Message object in this field will not contain further
109
     * reply_to_message fields even if it itself is a reply.
110
     *
111
     * @var \TelegramBot\Api\Types\Message
112
     */
113
    protected $replyToMessage;
114
115
    /**
116
     * Optional. For text messages, the actual UTF-8 text of the message
117
     *
118
     * @var string
119
     */
120
    protected $text;
121
122
    /**
123
     * Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text.
124
     * array of \TelegramBot\Api\Types\MessageEntity
125
     *
126
     * @var array
127
     */
128
    protected $entities;
129
130
    /**
131
     * Optional. Message is an audio file, information about the file
132
     *
133
     * @var \TelegramBot\Api\Types\Audio
134
     */
135
    protected $audio;
136
137
    /**
138
     * Optional. Message is a general file, information about the file
139
     *
140
     * @var \TelegramBot\Api\Types\Document
141
     */
142
    protected $document;
143
144
    /**
145
     * Optional. Message is a photo, available sizes of the photo
146
     * array of \TelegramBot\Api\Types\Photo
147
     *
148
     * @var array
149
     */
150
    protected $photo;
151
152
    /**
153
     * Optional. Message is a sticker, information about the sticker
154
     *
155
     * @var \TelegramBot\Api\Types\Sticker
156
     */
157
    protected $sticker;
158
159
    /**
160
     * Optional. Message is a video, information about the video
161
     *
162
     * @var \TelegramBot\Api\Types\Video
163
     */
164
    protected $video;
165
166
    /**
167
     * Optional. Message is a voice message, information about the file
168
     *
169
     * @var \TelegramBot\Api\Types\Voice
170
     */
171
    protected $voice;
172
173
    /**
174
     * Optional. Message is a shared contact, information about the contact
175
     *
176
     * @var \TelegramBot\Api\Types\Contact
177
     */
178
    protected $contact;
179
180
    /**
181
     * Optional. Message is a shared location, information about the location
182
     *
183
     * @var \TelegramBot\Api\Types\Location
184
     */
185
    protected $location;
186
187
    /**
188
     * Optional. Message is a venue, information about the venue
189
     *
190
     * @var \TelegramBot\Api\Types\Venue
191
     */
192
    protected $venue;
193
194
    /**
195
     * Optional. A new member was added to the group, information about them (this member may be bot itself)
196
     *
197
     * @var \TelegramBot\Api\Types\User
198
     */
199
    protected $newChatMember;
200
201
    /**
202
     * Optional. Array of new members was added to the group, information about they (this members may contains bot itself)
203
     *
204
     * @var \TelegramBot\Api\Types\ArrayOfUsers
205
     */
206
    protected $newChatMembers;
207
208
    /**
209
     * Optional. A member was removed from the group, information about them (this member may be bot itself)
210
     *
211
     * @var \TelegramBot\Api\Types\User
212
     */
213
    protected $leftChatMember;
214
215
    /**
216
     * Optional. A group title was changed to this value
217
     *
218
     * @var string
219
     */
220
    protected $newChatTitle;
221
222
    /**
223
     * Optional. A group photo was change to this value
224
     *
225
     * @var mixed
226
     */
227
    protected $newChatPhoto;
228
229
    /**
230
     * Optional. Informs that the group photo was deleted
231
     *
232
     * @var bool
233
     */
234
    protected $deleteChatPhoto;
235
236
    /**
237
     * Optional. Informs that the group has been created
238
     *
239
     * @var bool
240
     */
241
    protected $groupChatCreated;
242
243
    /**
244
     * Optional. Text description of the video (usually empty)
245
     *
246
     * @var string
247
     */
248
    protected $caption;
249
250
251
    /**
252
     * Optional. Service message: the supergroup has been created
253
     *
254
     * @var bool
255
     */
256
    protected $supergroupChatCreated;
257
258
    /**
259
     * Optional. Service message: the channel has been created
260
     *
261
     * @var bool
262
     */
263
    protected $channelChatCreated;
264
265
    /**
266
     * Optional. The group has been migrated to a supergroup with the specified identifier,
267
     * not exceeding 1e13 by absolute value
268
     *
269
     * @var int
270
     */
271
    protected $migrateToChatId;
272
273
    /**
274
     * Optional. The supergroup has been migrated from a group with the specified identifier,
275
     * not exceeding 1e13 by absolute value
276
     *
277
     * @var int
278
     */
279
    protected $migrateFromChatId;
280
281
    /**
282
     * Optional. Specified message was pinned.Note that the Message object in this field
283
     * will not contain further reply_to_message fields even if it is itself a reply.
284
     *
285
     * @var Message
286
     */
287
    protected $pinnedMessage;
288
289
    /**
290
     * Optional. Message is an invoice for a payment, information about the invoice.
291
     *
292
     * @var Invoice
293
     */
294
    protected $invoice;
295
296
    /**
297
     * Optional. Message is a service message about a successful payment, information about the payment.
298
     *
299
     * @var SuccessfulPayment
300
     */
301
    protected $successfulPayment;
302
303
    /**
304
     * Optional. For messages forwarded from channels, signature of the post author if present
305
     *
306
     * @var string
307
     */
308
    protected $forwardSignature;
309
310
    /**
311
     * Optional. Signature of the post author for messages in channels
312
     *
313
     * @var string
314
     */
315
    protected $authorSignature;
316
317
    /**
318
     * Optional. For messages with a caption, special entities like usernames,
319
     * URLs, bot commands, etc. that appear in the caption
320
     *
321
     * @var ArrayOfMessageEntity
322
     */
323
    protected $captionEntities;
324
325
    /**
326
     * Optional. The domain name of the website on which the user has logged in.
327
     *
328
     * @var string
329
     */
330
    protected $connectedWebsite;
331
332
    /**
333
     * @return string
334
     */
335 1
    public function getCaption()
336
    {
337 1
        return $this->caption;
338
    }
339
340
    /**
341
     * @param string $caption
342
     */
343 2
    public function setCaption($caption)
344
    {
345 2
        $this->caption = $caption;
346 2
    }
347
348
    /**
349
     * @return Audio
350
     */
351 1
    public function getAudio()
352
    {
353 1
        return $this->audio;
354
    }
355
356
    /**
357
     * @param Audio $audio
358
     */
359 2
    public function setAudio(Audio $audio)
360
    {
361 2
        $this->audio = $audio;
362 2
    }
363
364
    /**
365
     * @return Chat
366
     */
367 2
    public function getChat()
368
    {
369 2
        return $this->chat;
370
    }
371
372
    /**
373
     * @param Chat $chat
374
     */
375 15
    public function setChat(Chat $chat)
376
    {
377 15
        $this->chat = $chat;
378 15
    }
379
380
    /**
381
     * @return Contact
382
     */
383 1
    public function getContact()
384
    {
385 1
        return $this->contact;
386
    }
387
388
    /**
389
     * @param Contact $contact
390
     */
391 2
    public function setContact(Contact $contact)
392
    {
393 2
        $this->contact = $contact;
394 2
    }
395
396
    /**
397
     * @return int
398
     */
399 1
    public function getDate()
400
    {
401 1
        return $this->date;
402
    }
403
404
    /**
405
     * @param int $date
406
     *
407
     * @throws InvalidArgumentException
408
     */
409 14
    public function setDate($date)
410
    {
411 14
        if (is_integer($date)) {
412 13
            $this->date = $date;
413 13
        } else {
414 1
            throw new InvalidArgumentException();
415
        }
416 13
    }
417
418
    /**
419
     * @return boolean
420
     */
421 1
    public function isDeleteChatPhoto()
422
    {
423 1
        return $this->deleteChatPhoto;
424
    }
425
426
    /**
427
     * @param boolean $deleteChatPhoto
428
     */
429 2
    public function setDeleteChatPhoto($deleteChatPhoto)
430
    {
431 2
        $this->deleteChatPhoto = (bool)$deleteChatPhoto;
432 2
    }
433
434
    /**
435
     * @return Document
436
     */
437 1
    public function getDocument()
438
    {
439 1
        return $this->document;
440
    }
441
442
    /**
443
     * @param Document $document
444
     */
445 2
    public function setDocument($document)
446
    {
447 2
        $this->document = $document;
448 2
    }
449
450
    /**
451
     * @return int
452
     */
453 1
    public function getForwardDate()
454
    {
455 1
        return $this->forwardDate;
456
    }
457
458
    /**
459
     * @param int $forwardDate
460
     *
461
     * @throws InvalidArgumentException
462
     */
463 3
    public function setForwardDate($forwardDate)
464
    {
465 3
        if (is_integer($forwardDate)) {
466 2
            $this->forwardDate = $forwardDate;
467 2
        } else {
468 1
            throw new InvalidArgumentException();
469
        }
470 2
    }
471
472
    /**
473
     * @return User
474
     */
475 1
    public function getForwardFrom()
476
    {
477 1
        return $this->forwardFrom;
478
    }
479
480
    /**
481
     * @param User $forwardFrom
482
     */
483 2
    public function setForwardFrom(User $forwardFrom)
484
    {
485 2
        $this->forwardFrom = $forwardFrom;
486 2
    }
487
488
    /**
489
     * @return boolean
490
     */
491 1
    public function isGroupChatCreated()
492
    {
493 1
        return $this->groupChatCreated;
494
    }
495
496
    /**
497
     * @param boolean $groupChatCreated
498
     */
499 2
    public function setGroupChatCreated($groupChatCreated)
500
    {
501 2
        $this->groupChatCreated = (bool)$groupChatCreated;
502 2
    }
503
504
    /**
505
     * @return User
506
     */
507 1
    public function getLeftChatMember()
508
    {
509 1
        return $this->leftChatMember;
510
    }
511
512
    /**
513
     * @param User $leftChatMember
514
     */
515 2
    public function setLeftChatMember($leftChatMember)
516
    {
517 2
        $this->leftChatMember = $leftChatMember;
518 2
    }
519
520
    /**
521
     * @return Location
522
     */
523 1
    public function getLocation()
524
    {
525 1
        return $this->location;
526
    }
527
528
    /**
529
     * @param Location $location
530
     */
531 2
    public function setLocation(Location $location)
532
    {
533 2
        $this->location = $location;
534 2
    }
535
536
    /**
537
     * @return Venue
538
     */
539
    public function getVenue()
540
    {
541
        return $this->venue;
542
    }
543
544
    /**
545
     * @param Venue $venue
546
     */
547
    public function setVenue($venue)
548
    {
549
        $this->venue = $venue;
550
    }
551
552
    /**
553
     * @return int
554
     */
555 1
    public function getMessageId()
556
    {
557 1
        return $this->messageId;
558
    }
559
560
    /**
561
     * @param int $messageId
562
     *
563
     * @throws InvalidArgumentException
564
     */
565 15
    public function setMessageId($messageId)
566
    {
567 15
        if (is_integer($messageId) || is_float($messageId)) {
568 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...
569 14
        } else {
570 1
            throw new InvalidArgumentException();
571
        }
572 14
    }
573
574
    /**
575
     * @return User
576
     */
577 1
    public function getNewChatMember()
578
    {
579 1
        return $this->newChatMember;
580
    }
581
582
    /**
583
     * @param User $newChatMember
584
     */
585 2
    public function setNewChatMember($newChatMember)
586
    {
587 2
        $this->newChatMember = $newChatMember;
588 2
    }
589
590
    /**
591
     * @return ArrayOfUsers
592
     */
593
    public function getNewChatMembers()
594
    {
595
        return $this->newChatMembers;
596
    }
597
598
    /**
599
     * @param User $newChatMembers
600
     */
601
    public function setNewChatMembers($newChatMembers)
602
    {
603
        $this->newChatMembers = $newChatMembers;
0 ignored issues
show
Documentation Bug introduced by
It seems like $newChatMembers of type object<TelegramBot\Api\Types\User> is incompatible with the declared type object<TelegramBot\Api\Types\ArrayOfUsers> of property $newChatMembers.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
604
    }
605
606
    /**
607
     * @return array
608
     */
609 1
    public function getNewChatPhoto()
610
    {
611 1
        return $this->newChatPhoto;
612
    }
613
614
    /**
615
     * @param array $newChatPhoto
616
     */
617 2
    public function setNewChatPhoto($newChatPhoto)
618
    {
619 2
        $this->newChatPhoto = $newChatPhoto;
620 2
    }
621
622
    /**
623
     * @return string
624
     */
625 1
    public function getNewChatTitle()
626
    {
627 1
        return $this->newChatTitle;
628
    }
629
630
    /**
631
     * @param string $newChatTitle
632
     */
633 2
    public function setNewChatTitle($newChatTitle)
634
    {
635 2
        $this->newChatTitle = $newChatTitle;
636 2
    }
637
638
    /**
639
     * @return array
640
     */
641 1
    public function getPhoto()
642
    {
643 1
        return $this->photo;
644
    }
645
646
    /**
647
     * @param array $photo
648
     */
649 2
    public function setPhoto(array $photo)
650
    {
651 2
        $this->photo = $photo;
652 2
    }
653
654
    /**
655
     * @return Message
656
     */
657 1
    public function getReplyToMessage()
658
    {
659 1
        return $this->replyToMessage;
660
    }
661
662
    /**
663
     * @param Message $replyToMessage
664
     */
665 2
    public function setReplyToMessage(Message $replyToMessage)
666
    {
667 2
        $this->replyToMessage = $replyToMessage;
668 2
    }
669
670
    /**
671
     * @return Sticker
672
     */
673 1
    public function getSticker()
674
    {
675 1
        return $this->sticker;
676
    }
677
678
    /**
679
     * @param Sticker $sticker
680
     */
681 2
    public function setSticker(Sticker $sticker)
682
    {
683 2
        $this->sticker = $sticker;
684 2
    }
685
686
    /**
687
     * @return string
688
     */
689 7
    public function getText()
690
    {
691 7
        return $this->text;
692
    }
693
694
    /**
695
     * @param string $text
696
     */
697 5
    public function setText($text)
698
    {
699 5
        $this->text = $text;
700 5
    }
701
702
    /**
703
     * @return array
704
     */
705
    public function getEntities()
706
    {
707
        return $this->entities;
708
    }
709
710
    /**
711
     * @param array $entities
712
     */
713 1
    public function setEntities($entities)
714
    {
715 1
        $this->entities = $entities;
716 1
    }
717
718
    /**
719
     * @return User
720
     */
721 1
    public function getFrom()
722
    {
723 1
        return $this->from;
724
    }
725
726
    /**
727
     * @param User $from
728
     */
729 13
    public function setFrom(User $from)
730
    {
731 13
        $this->from = $from;
732 13
    }
733
734
    /**
735
     * @return Video
736
     */
737 1
    public function getVideo()
738
    {
739 1
        return $this->video;
740
    }
741
742
    /**
743
     * @param Video $video
744
     */
745 2
    public function setVideo(Video $video)
746
    {
747 2
        $this->video = $video;
748 2
    }
749
750
    /**
751
     * @return Voice
752
     */
753 1
    public function getVoice()
754
    {
755 1
        return $this->voice;
756
    }
757
758
    /**
759
     * @param Voice $voice
760
     */
761 2
    public function setVoice($voice)
762
    {
763 2
        $this->voice = $voice;
764 2
    }
765
766
    /**
767
     * @param boolean $supergroupChatCreated
768
     */
769 2
    public function setSupergroupChatCreated($supergroupChatCreated)
770
    {
771 2
        $this->supergroupChatCreated = $supergroupChatCreated;
772 2
    }
773
774
    /**
775
     * @return boolean
776
     */
777 1
    public function isSupergroupChatCreated()
778
    {
779 1
        return $this->supergroupChatCreated;
780
    }
781
782
    /**
783
     * @param boolean $channelChatCreated
784
     */
785 2
    public function setChannelChatCreated($channelChatCreated)
786
    {
787 2
        $this->channelChatCreated = $channelChatCreated;
788 2
    }
789
790
    /**
791
     * @return boolean
792
     */
793 1
    public function isChannelChatCreated()
794
    {
795 1
        return $this->channelChatCreated;
796
    }
797
798
    /**
799
     * @param int $migrateToChatId
800
     */
801 2
    public function setMigrateToChatId($migrateToChatId)
802
    {
803 2
        $this->migrateToChatId = $migrateToChatId;
804 2
    }
805
806
    /**
807
     * @return int
808
     */
809 1
    public function getMigrateToChatId()
810
    {
811 1
        return $this->migrateToChatId;
812
    }
813
814
    /**
815
     * @param int $migrateFromChatId
816
     */
817 4
    public function setMigrateFromChatId($migrateFromChatId)
818
    {
819 4
        $this->migrateFromChatId = $migrateFromChatId;
820 4
    }
821
822
    /**
823
     * @return int
824
     */
825 1
    public function getMigrateFromChatId()
826
    {
827 1
        return $this->migrateFromChatId;
828
    }
829
830
    /**
831
     * @return Message
832
     */
833
    public function getPinnedMessage()
834
    {
835
        return $this->pinnedMessage;
836
    }
837
838
    /**
839
     * @param Message $pinnedMessage
840
     */
841
    public function setPinnedMessage($pinnedMessage)
842
    {
843
        $this->pinnedMessage = $pinnedMessage;
844
    }
845
846
    /**
847
     * @author MY
848
     * @return Invoice
849
     */
850
    public function getInvoice()
851
    {
852
        return $this->invoice;
853
    }
854
855
    /**
856
     * @author MY
857
     * @param Invoice $invoice
858
     */
859
    public function setInvoice($invoice)
860
    {
861
        $this->invoice = $invoice;
862
    }
863
864
    /**
865
     * @author MY
866
     * @return SuccessfulPayment
867
     */
868
    public function getSuccessfulPayment()
869
    {
870
        return $this->successfulPayment;
871
    }
872
873
    /**
874
     * @author MY
875
     * @param SuccessfulPayment $successfulPayment
876
     */
877
    public function setSuccessfulPayment($successfulPayment)
878
    {
879
        $this->successfulPayment = $successfulPayment;
880
    }
881
882
    /**
883
     * @return string
884
     */
885
    public function getForwardSignature()
886
    {
887
        return $this->forwardSignature;
888
    }
889
890
    /**
891
     * @param string $forwardSignature
892
     */
893
    public function setForwardSignature($forwardSignature)
894
    {
895
        $this->forwardSignature = $forwardSignature;
896
    }
897
898
    /**
899
     * @return string
900
     */
901
    public function getAuthorSignature()
902
    {
903
        return $this->authorSignature;
904
    }
905
906
    /**
907
     * @param string $authorSignature
908
     */
909
    public function setAuthorSignature($authorSignature)
910
    {
911
        $this->authorSignature = $authorSignature;
912
    }
913
914
    /**
915
     * @return ArrayOfMessageEntity
916
     */
917
    public function getCaptionEntities()
918
    {
919
        return $this->captionEntities;
920
    }
921
922
    /**
923
     * @param ArrayOfMessageEntity $captionEntities
924
     */
925
    public function setCaptionEntities($captionEntities)
926
    {
927
        $this->captionEntities = $captionEntities;
928
    }
929
930
    /**
931
     * @return string
932
     */
933
    public function getConnectedWebsite()
934
    {
935
        return $this->connectedWebsite;
936
    }
937
938
    /**
939
     * @param string $connectedWebsite
940
     */
941
    public function setConnectedWebsite($connectedWebsite)
942
    {
943
        $this->connectedWebsite = $connectedWebsite;
944
    }
945
}
946