Code Duplication    Length = 17-21 lines in 10 locations

src/BotApi.php 10 locations

@@ 322-340 (lines=19) @@
319
     * @throws \TelegramBot\Api\InvalidArgumentException
320
     * @throws \TelegramBot\Api\Exception
321
     */
322
    public function sendMessage(
323
        $chatId,
324
        $text,
325
        $parseMode = null,
326
        $disablePreview = false,
327
        $replyToMessageId = null,
328
        $replyMarkup = null,
329
        $disableNotification = false
330
    ) {
331
        return Message::fromResponse($this->call('sendMessage', [
332
            'chat_id' => $chatId,
333
            'text' => $text,
334
            'parse_mode' => $parseMode,
335
            'disable_web_page_preview' => $disablePreview,
336
            'reply_to_message_id' => (int)$replyToMessageId,
337
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
338
            'disable_notification' => (bool)$disableNotification,
339
        ]));
340
    }
341
342
    /**
343
     * Use this method to send phone contacts
@@ 357-375 (lines=19) @@
354
     * @return \TelegramBot\Api\Types\Message
355
     * @throws \TelegramBot\Api\Exception
356
     */
357
    public function sendContact(
358
        $chatId,
359
        $phoneNumber,
360
        $firstName,
361
        $lastName = null,
362
        $replyToMessageId = null,
363
        $replyMarkup = null,
364
        $disableNotification = false
365
    ) {
366
        return Message::fromResponse($this->call('sendContact', [
367
            'chat_id' => $chatId,
368
            'phone_number' => $phoneNumber,
369
            'first_name' => $firstName,
370
            'last_name' => $lastName,
371
            'reply_to_message_id' => $replyToMessageId,
372
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
373
            'disable_notification' => (bool)$disableNotification,
374
        ]));
375
    }
376
377
    /**
378
     * Use this method when you need to tell the user that something is happening on the bot's side.
@@ 514-532 (lines=19) @@
511
     * @param null|int                                                                $livePeriod
512
     * @return \TelegramBot\Api\Types\Message
513
     */
514
    public function sendLocation(
515
        $chatId,
516
        $latitude,
517
        $longitude,
518
        $replyToMessageId = null,
519
        $replyMarkup = null,
520
        $disableNotification = false,
521
        $livePeriod = null
522
    ) {
523
        return Message::fromResponse($this->call('sendLocation', [
524
            'chat_id'              => $chatId,
525
            'latitude'             => $latitude,
526
            'longitude'            => $longitude,
527
            'live_period'          => $livePeriod,
528
            'reply_to_message_id'  => $replyToMessageId,
529
            'reply_markup'         => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
530
            'disable_notification' => (bool)$disableNotification,
531
        ]));
532
    }
533
534
    /**
535
     * Use this method to edit live location messages sent by the bot or via the bot (for inline bots).
@@ 723-743 (lines=21) @@
720
     * @throws \TelegramBot\Api\InvalidArgumentException
721
     * @throws \TelegramBot\Api\Exception
722
     */
723
    public function sendAnimation(
724
        $chatId,
725
        $animation,
726
        $duration = null,
727
        $caption = null,
728
        $replyToMessageId = null,
729
        $replyMarkup = null,
730
        $disableNotification = false,
731
        $parseMode = null
732
    ) {
733
        return Message::fromResponse($this->call('sendAnimation', [
734
            'chat_id' => $chatId,
735
            'animation' => $animation,
736
            'duration' => $duration,
737
            'caption' => $caption,
738
            'reply_to_message_id' => $replyToMessageId,
739
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
740
            'disable_notification' => (bool)$disableNotification,
741
            'parse_mode' => $parseMode
742
        ]));
743
    }
744
745
    /**
746
     * Use this method to send audio files,
@@ 766-784 (lines=19) @@
763
     * @throws \TelegramBot\Api\InvalidArgumentException
764
     * @throws \TelegramBot\Api\Exception
765
     */
766
    public function sendVoice(
767
        $chatId,
768
        $voice,
769
        $duration = null,
770
        $replyToMessageId = null,
771
        $replyMarkup = null,
772
        $disableNotification = false,
773
        $parseMode = null
774
    ) {
775
        return Message::fromResponse($this->call('sendVoice', [
776
            'chat_id' => $chatId,
777
            'voice' => $voice,
778
            'duration' => $duration,
779
            'reply_to_message_id' => $replyToMessageId,
780
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
781
            'disable_notification' => (bool)$disableNotification,
782
            'parse_mode' => $parseMode
783
        ]));
784
    }
785
786
    /**
787
     * Use this method to forward messages of any kind. On success, the sent Message is returned.
@@ 879-897 (lines=19) @@
876
     * @throws \TelegramBot\Api\InvalidArgumentException
877
     * @throws \TelegramBot\Api\Exception
878
     */
879
    public function sendPhoto(
880
        $chatId,
881
        $photo,
882
        $caption = null,
883
        $replyToMessageId = null,
884
        $replyMarkup = null,
885
        $disableNotification = false,
886
        $parseMode = null
887
    ) {
888
        return Message::fromResponse($this->call('sendPhoto', [
889
            'chat_id' => $chatId,
890
            'photo' => $photo,
891
            'caption' => $caption,
892
            'reply_to_message_id' => $replyToMessageId,
893
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
894
            'disable_notification' => (bool)$disableNotification,
895
            'parse_mode' => $parseMode
896
        ]));
897
    }
898
899
    /**
900
     * Use this method to send general files. On success, the sent Message is returned.
@@ 916-934 (lines=19) @@
913
     * @throws \TelegramBot\Api\InvalidArgumentException
914
     * @throws \TelegramBot\Api\Exception
915
     */
916
    public function sendDocument(
917
        $chatId,
918
        $document,
919
        $caption = null,
920
        $replyToMessageId = null,
921
        $replyMarkup = null,
922
        $disableNotification = false,
923
        $parseMode = null
924
    ) {
925
        return Message::fromResponse($this->call('sendDocument', [
926
            'chat_id' => $chatId,
927
            'document' => $document,
928
            'caption' => $caption,
929
            'reply_to_message_id' => $replyToMessageId,
930
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
931
            'disable_notification' => (bool)$disableNotification,
932
            'parse_mode' => $parseMode
933
        ]));
934
    }
935
936
    /**
937
     * Use this method to get basic info about a file and prepare it for downloading.
@@ 1094-1112 (lines=19) @@
1091
     *        Types\ReplyKeyboardRemove|null $replyMarkup
1092
     * @return Message
1093
     */
1094
    public function editMessageText(
1095
        $chatId,
1096
        $messageId,
1097
        $text,
1098
        $parseMode = null,
1099
        $disablePreview = false,
1100
        $replyMarkup = null,
1101
        $inlineMessageId = null
1102
    ) {
1103
        return Message::fromResponse($this->call('editMessageText', [
1104
            'chat_id' => $chatId,
1105
            'message_id' => $messageId,
1106
            'text' => $text,
1107
            'inline_message_id' => $inlineMessageId,
1108
            'parse_mode' => $parseMode,
1109
            'disable_web_page_preview' => $disablePreview,
1110
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
1111
        ]));
1112
    }
1113
1114
    /**
1115
     * Use this method to edit text messages sent by the bot or via the bot
@@ 1685-1703 (lines=19) @@
1682
     * @throws \TelegramBot\Api\InvalidArgumentException
1683
     * @throws \TelegramBot\Api\Exception
1684
     */
1685
    public function sendVideoNote(
1686
        $chatId,
1687
        $videoNote,
1688
        $duration = null,
1689
        $length = null,
1690
        $replyToMessageId = null,
1691
        $replyMarkup = null,
1692
        $disableNotification = false
1693
    ) {
1694
        return Message::fromResponse($this->call('sendVideoNote', [
1695
            'chat_id' => $chatId,
1696
            'video_note' => $videoNote,
1697
            'duration' => $duration,
1698
            'length' => $length,
1699
            'reply_to_message_id' => $replyToMessageId,
1700
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
1701
            'disable_notification' => (bool)$disableNotification
1702
        ]));
1703
    }
1704
1705
    /**
1706
     * Use this method to send a group of photos or videos as an album.
@@ 1773-1789 (lines=17) @@
1770
     * @throws \TelegramBot\Api\InvalidArgumentException
1771
     * @throws \TelegramBot\Api\Exception
1772
     */
1773
    public function sendPoll(
1774
        $chatId,
1775
        $question,
1776
        $options,
1777
        $disableNotification = false,
1778
        $replyToMessageId = null,
1779
        $replyMarkup = null
1780
    ) {
1781
        return Message::fromResponse($this->call('sendPoll', [
1782
            'chat_id' => $chatId,
1783
            'question' => $question,
1784
            'options' => json_encode($options),
1785
            'disable_notification' => (bool)$disableNotification,
1786
            'reply_to_message_id' => (int)$replyToMessageId,
1787
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
1788
        ]));
1789
    }
1790
1791
    /**
1792
     * Use this method to stop a poll which was sent by the bot.