Code Duplication    Length = 13-20 lines in 9 locations

src/BotApi.php 9 locations

@@ 338-356 (lines=19) @@
335
     * @return \TelegramBot\Api\Types\Message
336
     * @throws \TelegramBot\Api\Exception
337
     */
338
    public function sendContact(
339
        $chatId,
340
        $phoneNumber,
341
        $firstName,
342
        $lastName = null,
343
        $replyToMessageId = null,
344
        $replyMarkup = null,
345
        $disableNotification = false
346
    ) {
347
        return Message::fromResponse($this->call('sendContact', [
348
            'chat_id' => $chatId,
349
            'phone_number' => $phoneNumber,
350
            'first_name' => $firstName,
351
            'last_name' => $lastName,
352
            'reply_to_message_id' => $replyToMessageId,
353
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
354
            'disable_notification' => (bool)$disableNotification,
355
        ]));
356
    }
357
358
    /**
359
     * Use this method when you need to tell the user that something is happening on the bot's side.
@@ 481-500 (lines=20) @@
478
     * @param null|int                                                                $livePeriod
479
     * @return \TelegramBot\Api\Types\Message
480
     */
481
    public function sendLocation(
482
        $chatId,
483
        $latitude,
484
        $longitude,
485
        $replyToMessageId = null,
486
        $replyMarkup = null,
487
        $disableNotification = false,
488
        $livePeriod = null
489
    )
490
    {
491
        return Message::fromResponse($this->call('sendLocation', [
492
            'chat_id'              => $chatId,
493
            'latitude'             => $latitude,
494
            'longitude'            => $longitude,
495
            'live_period'          => $livePeriod,
496
            'reply_to_message_id'  => $replyToMessageId,
497
            'reply_markup'         => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
498
            'disable_notification' => (bool)$disableNotification,
499
        ]));
500
    }
501
502
    /**
503
     * Use this method to edit live location messages sent by the bot or via the bot (for inline bots).
@@ 542-555 (lines=14) @@
539
     * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|null $replyMarkup
540
     * @return \TelegramBot\Api\Types\Message
541
     */
542
    public function stopMessageLiveLocation(
543
        $chatId,
544
        $messageId,
545
        $inlineMessageId,
546
        $replyMarkup = null
547
    )
548
    {
549
        return Message::fromResponse($this->call('sendLocation', [
550
            'chat_id'           => $chatId,
551
            'message_id'        => $messageId,
552
            'inline_message_id' => $inlineMessageId,
553
            'reply_markup'      => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
554
        ]));
555
    }
556
557
    /**
558
     * Use this method to send information about a venue. On success, the sent Message is returned.
@@ 610-624 (lines=15) @@
607
     * @throws \TelegramBot\Api\InvalidArgumentException
608
     * @throws \TelegramBot\Api\Exception
609
     */
610
    public function sendSticker(
611
        $chatId,
612
        $sticker,
613
        $replyToMessageId = null,
614
        $replyMarkup = null,
615
        $disableNotification = false
616
    ) {
617
        return Message::fromResponse($this->call('sendSticker', [
618
            'chat_id' => $chatId,
619
            'sticker' => $sticker,
620
            'reply_to_message_id' => $replyToMessageId,
621
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
622
            'disable_notification' => (bool)$disableNotification,
623
        ]));
624
    }
625
626
    /**
627
     * Use this method to send video files,
@@ 682-698 (lines=17) @@
679
     * @throws \TelegramBot\Api\InvalidArgumentException
680
     * @throws \TelegramBot\Api\Exception
681
     */
682
    public function sendVoice(
683
        $chatId,
684
        $voice,
685
        $duration = null,
686
        $replyToMessageId = null,
687
        $replyMarkup = null,
688
        $disableNotification = false
689
    ) {
690
        return Message::fromResponse($this->call('sendVoice', [
691
            'chat_id' => $chatId,
692
            'voice' => $voice,
693
            'duration' => $duration,
694
            'reply_to_message_id' => $replyToMessageId,
695
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
696
            'disable_notification' => (bool)$disableNotification,
697
        ]));
698
    }
699
700
    /**
701
     * Use this method to forward messages of any kind. On success, the sent Message is returned.
@@ 787-803 (lines=17) @@
784
     * @throws \TelegramBot\Api\InvalidArgumentException
785
     * @throws \TelegramBot\Api\Exception
786
     */
787
    public function sendPhoto(
788
        $chatId,
789
        $photo,
790
        $caption = null,
791
        $replyToMessageId = null,
792
        $replyMarkup = null,
793
        $disableNotification = false
794
    ) {
795
        return Message::fromResponse($this->call('sendPhoto', [
796
            'chat_id' => $chatId,
797
            'photo' => $photo,
798
            'caption' => $caption,
799
            'reply_to_message_id' => $replyToMessageId,
800
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
801
            'disable_notification' => (bool)$disableNotification,
802
        ]));
803
    }
804
805
    /**
806
     * Use this method to send general files. On success, the sent Message is returned.
@@ 820-836 (lines=17) @@
817
     * @throws \TelegramBot\Api\InvalidArgumentException
818
     * @throws \TelegramBot\Api\Exception
819
     */
820
    public function sendDocument(
821
        $chatId,
822
        $document,
823
        $caption = null,
824
        $replyToMessageId = null,
825
        $replyMarkup = null,
826
        $disableNotification = false
827
    ) {
828
        return Message::fromResponse($this->call('sendDocument', [
829
            'chat_id' => $chatId,
830
            'document' => $document,
831
            'caption' => $caption,
832
            'reply_to_message_id' => $replyToMessageId,
833
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
834
            'disable_notification' => (bool)$disableNotification,
835
        ]));
836
    }
837
838
    /**
839
     * Use this method to get basic info about a file and prepare it for downloading.
@@ 995-1013 (lines=19) @@
992
     * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|null $replyMarkup
993
     * @return Message
994
     */
995
    public function editMessageText(
996
        $chatId,
997
        $messageId,
998
        $text,
999
        $parseMode = null,
1000
        $disablePreview = false,
1001
        $replyMarkup = null,
1002
        $inlineMessageId = null
1003
    ) {
1004
        return Message::fromResponse($this->call('editMessageText', [
1005
            'chat_id' => $chatId,
1006
            'message_id' => $messageId,
1007
            'text' => $text,
1008
            'inline_message_id' => $inlineMessageId,
1009
            'parse_mode' => $parseMode,
1010
            'disable_web_page_preview' => $disablePreview,
1011
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
1012
        ]));
1013
    }
1014
1015
    /**
1016
     * Use this method to edit text messages sent by the bot or via the bot
@@ 1054-1066 (lines=13) @@
1051
     *
1052
     * @return Message
1053
     */
1054
    public function editMessageReplyMarkup(
1055
        $chatId,
1056
        $messageId,
1057
        $replyMarkup = null,
1058
        $inlineMessageId = null
1059
    ) {
1060
        return Message::fromResponse($this->call('editMessageReplyMarkup', [
1061
            'chat_id' => $chatId,
1062
            'message_id' => $messageId,
1063
            'inline_message_id' => $inlineMessageId,
1064
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
1065
        ]));
1066
    }
1067
1068
    /**
1069
     * Use this method to delete a message, including service messages, with the following limitations: