Code Duplication    Length = 19-21 lines in 9 locations

src/BotApi.php 9 locations

@@ 321-339 (lines=19) @@
318
     * @throws \TelegramBot\Api\InvalidArgumentException
319
     * @throws \TelegramBot\Api\Exception
320
     */
321
    public function sendMessage(
322
        $chatId,
323
        $text,
324
        $parseMode = null,
325
        $disablePreview = false,
326
        $replyToMessageId = null,
327
        $replyMarkup = null,
328
        $disableNotification = false
329
    ) {
330
        return Message::fromResponse($this->call('sendMessage', [
331
            'chat_id' => $chatId,
332
            'text' => $text,
333
            'parse_mode' => $parseMode,
334
            'disable_web_page_preview' => $disablePreview,
335
            'reply_to_message_id' => (int)$replyToMessageId,
336
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
337
            'disable_notification' => (bool)$disableNotification,
338
        ]));
339
    }
340
341
    /**
342
     * Use this method to send phone contacts
@@ 356-374 (lines=19) @@
353
     * @return \TelegramBot\Api\Types\Message
354
     * @throws \TelegramBot\Api\Exception
355
     */
356
    public function sendContact(
357
        $chatId,
358
        $phoneNumber,
359
        $firstName,
360
        $lastName = null,
361
        $replyToMessageId = null,
362
        $replyMarkup = null,
363
        $disableNotification = false
364
    ) {
365
        return Message::fromResponse($this->call('sendContact', [
366
            'chat_id' => $chatId,
367
            'phone_number' => $phoneNumber,
368
            'first_name' => $firstName,
369
            'last_name' => $lastName,
370
            'reply_to_message_id' => $replyToMessageId,
371
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
372
            'disable_notification' => (bool)$disableNotification,
373
        ]));
374
    }
375
376
    /**
377
     * Use this method when you need to tell the user that something is happening on the bot's side.
@@ 500-518 (lines=19) @@
497
     * @param null|int                                                                $livePeriod
498
     * @return \TelegramBot\Api\Types\Message
499
     */
500
    public function sendLocation(
501
        $chatId,
502
        $latitude,
503
        $longitude,
504
        $replyToMessageId = null,
505
        $replyMarkup = null,
506
        $disableNotification = false,
507
        $livePeriod = null
508
    ) {
509
        return Message::fromResponse($this->call('sendLocation', [
510
            'chat_id'              => $chatId,
511
            'latitude'             => $latitude,
512
            'longitude'            => $longitude,
513
            'live_period'          => $livePeriod,
514
            'reply_to_message_id'  => $replyToMessageId,
515
            'reply_markup'         => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
516
            'disable_notification' => (bool)$disableNotification,
517
        ]));
518
    }
519
520
    /**
521
     * Use this method to edit live location messages sent by the bot or via the bot (for inline bots).
@@ 709-729 (lines=21) @@
706
     * @throws \TelegramBot\Api\InvalidArgumentException
707
     * @throws \TelegramBot\Api\Exception
708
     */
709
    public function sendAnimation(
710
        $chatId,
711
        $animation,
712
        $duration = null,
713
        $caption = null,
714
        $replyToMessageId = null,
715
        $replyMarkup = null,
716
        $disableNotification = false,
717
        $parseMode = null
718
    ) {
719
        return Message::fromResponse($this->call('sendAnimation', [
720
            'chat_id' => $chatId,
721
            'animation' => $animation,
722
            'duration' => $duration,
723
            'caption' => $caption,
724
            'reply_to_message_id' => $replyToMessageId,
725
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
726
            'disable_notification' => (bool)$disableNotification,
727
            'parse_mode' => $parseMode
728
        ]));
729
    }
730
731
    /**
732
     * Use this method to send audio files,
@@ 752-770 (lines=19) @@
749
     * @throws \TelegramBot\Api\InvalidArgumentException
750
     * @throws \TelegramBot\Api\Exception
751
     */
752
    public function sendVoice(
753
        $chatId,
754
        $voice,
755
        $duration = null,
756
        $replyToMessageId = null,
757
        $replyMarkup = null,
758
        $disableNotification = false,
759
        $parseMode = null
760
    ) {
761
        return Message::fromResponse($this->call('sendVoice', [
762
            'chat_id' => $chatId,
763
            'voice' => $voice,
764
            'duration' => $duration,
765
            'reply_to_message_id' => $replyToMessageId,
766
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
767
            'disable_notification' => (bool)$disableNotification,
768
            'parse_mode' => $parseMode
769
        ]));
770
    }
771
772
    /**
773
     * Use this method to forward messages of any kind. On success, the sent Message is returned.
@@ 865-883 (lines=19) @@
862
     * @throws \TelegramBot\Api\InvalidArgumentException
863
     * @throws \TelegramBot\Api\Exception
864
     */
865
    public function sendPhoto(
866
        $chatId,
867
        $photo,
868
        $caption = null,
869
        $replyToMessageId = null,
870
        $replyMarkup = null,
871
        $disableNotification = false,
872
        $parseMode = null
873
    ) {
874
        return Message::fromResponse($this->call('sendPhoto', [
875
            'chat_id' => $chatId,
876
            'photo' => $photo,
877
            'caption' => $caption,
878
            'reply_to_message_id' => $replyToMessageId,
879
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
880
            'disable_notification' => (bool)$disableNotification,
881
            'parse_mode' => $parseMode
882
        ]));
883
    }
884
885
    /**
886
     * Use this method to send general files. On success, the sent Message is returned.
@@ 902-920 (lines=19) @@
899
     * @throws \TelegramBot\Api\InvalidArgumentException
900
     * @throws \TelegramBot\Api\Exception
901
     */
902
    public function sendDocument(
903
        $chatId,
904
        $document,
905
        $caption = null,
906
        $replyToMessageId = null,
907
        $replyMarkup = null,
908
        $disableNotification = false,
909
        $parseMode = null
910
    ) {
911
        return Message::fromResponse($this->call('sendDocument', [
912
            'chat_id' => $chatId,
913
            'document' => $document,
914
            'caption' => $caption,
915
            'reply_to_message_id' => $replyToMessageId,
916
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
917
            'disable_notification' => (bool)$disableNotification,
918
            'parse_mode' => $parseMode
919
        ]));
920
    }
921
922
    /**
923
     * Use this method to get basic info about a file and prepare it for downloading.
@@ 1080-1098 (lines=19) @@
1077
     *        Types\ReplyKeyboardRemove|null $replyMarkup
1078
     * @return Message
1079
     */
1080
    public function editMessageText(
1081
        $chatId,
1082
        $messageId,
1083
        $text,
1084
        $parseMode = null,
1085
        $disablePreview = false,
1086
        $replyMarkup = null,
1087
        $inlineMessageId = null
1088
    ) {
1089
        return Message::fromResponse($this->call('editMessageText', [
1090
            'chat_id' => $chatId,
1091
            'message_id' => $messageId,
1092
            'text' => $text,
1093
            'inline_message_id' => $inlineMessageId,
1094
            'parse_mode' => $parseMode,
1095
            'disable_web_page_preview' => $disablePreview,
1096
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
1097
        ]));
1098
    }
1099
1100
    /**
1101
     * Use this method to edit text messages sent by the bot or via the bot
@@ 1671-1689 (lines=19) @@
1668
     * @throws \TelegramBot\Api\InvalidArgumentException
1669
     * @throws \TelegramBot\Api\Exception
1670
     */
1671
    public function sendVideoNote(
1672
        $chatId,
1673
        $videoNote,
1674
        $duration = null,
1675
        $length = null,
1676
        $replyToMessageId = null,
1677
        $replyMarkup = null,
1678
        $disableNotification = false
1679
    ) {
1680
        return Message::fromResponse($this->call('sendVideoNote', [
1681
            'chat_id' => $chatId,
1682
            'video_note' => $videoNote,
1683
            'duration' => $duration,
1684
            'length' => $length,
1685
            'reply_to_message_id' => $replyToMessageId,
1686
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
1687
            'disable_notification' => (bool)$disableNotification
1688
        ]));
1689
    }
1690
1691
    /**
1692
     * Use this method to send a group of photos or videos as an album.