Code Duplication    Length = 15-19 lines in 7 locations

src/BotApi.php 7 locations

@@ 331-349 (lines=19) @@
328
     * @return \TelegramBot\Api\Types\Message
329
     * @throws \TelegramBot\Api\Exception
330
     */
331
    public function sendContact(
332
        $chatId,
333
        $phoneNumber,
334
        $firstName,
335
        $lastName = null,
336
        $replyToMessageId = null,
337
        $replyMarkup = null,
338
        $disableNotification = false
339
    ) {
340
        return Message::fromResponse($this->call('sendContact', [
341
            'chat_id' => $chatId,
342
            'phone_number' => $phoneNumber,
343
            'first_name' => $firstName,
344
            'last_name' => $lastName,
345
            'reply_to_message_id' => $replyToMessageId,
346
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
347
            'disable_notification' => (bool)$disableNotification,
348
        ]));
349
    }
350
351
    /**
352
     * Use this method when you need to tell the user that something is happening on the bot's side.
@@ 474-490 (lines=17) @@
471
     * @return \TelegramBot\Api\Types\Message
472
     * @throws \TelegramBot\Api\Exception
473
     */
474
    public function sendLocation(
475
        $chatId,
476
        $latitude,
477
        $longitude,
478
        $replyToMessageId = null,
479
        $replyMarkup = null,
480
        $disableNotification = false
481
    ) {
482
        return Message::fromResponse($this->call('sendLocation', [
483
            'chat_id' => $chatId,
484
            'latitude' => $latitude,
485
            'longitude' => $longitude,
486
            'reply_to_message_id' => $replyToMessageId,
487
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
488
            'disable_notification' => (bool)$disableNotification,
489
        ]));
490
    }
491
492
    /**
493
     * Use this method to send information about a venue. On success, the sent Message is returned.
@@ 545-559 (lines=15) @@
542
     * @throws \TelegramBot\Api\InvalidArgumentException
543
     * @throws \TelegramBot\Api\Exception
544
     */
545
    public function sendSticker(
546
        $chatId,
547
        $sticker,
548
        $replyToMessageId = null,
549
        $replyMarkup = null,
550
        $disableNotification = false
551
    ) {
552
        return Message::fromResponse($this->call('sendSticker', [
553
            'chat_id' => $chatId,
554
            'sticker' => $sticker,
555
            'reply_to_message_id' => $replyToMessageId,
556
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
557
            'disable_notification' => (bool)$disableNotification,
558
        ]));
559
    }
560
561
    /**
562
     * Use this method to send video files,
@@ 617-633 (lines=17) @@
614
     * @throws \TelegramBot\Api\InvalidArgumentException
615
     * @throws \TelegramBot\Api\Exception
616
     */
617
    public function sendVoice(
618
        $chatId,
619
        $voice,
620
        $duration = null,
621
        $replyToMessageId = null,
622
        $replyMarkup = null,
623
        $disableNotification = false
624
    ) {
625
        return Message::fromResponse($this->call('sendVoice', [
626
            'chat_id' => $chatId,
627
            'voice' => $voice,
628
            'duration' => $duration,
629
            'reply_to_message_id' => $replyToMessageId,
630
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
631
            'disable_notification' => (bool)$disableNotification,
632
        ]));
633
    }
634
635
    /**
636
     * Use this method to forward messages of any kind. On success, the sent Message is returned.
@@ 722-738 (lines=17) @@
719
     * @throws \TelegramBot\Api\InvalidArgumentException
720
     * @throws \TelegramBot\Api\Exception
721
     */
722
    public function sendPhoto(
723
        $chatId,
724
        $photo,
725
        $caption = null,
726
        $replyToMessageId = null,
727
        $replyMarkup = null,
728
        $disableNotification = false
729
    ) {
730
        return Message::fromResponse($this->call('sendPhoto', [
731
            'chat_id' => $chatId,
732
            'photo' => $photo,
733
            'caption' => $caption,
734
            'reply_to_message_id' => $replyToMessageId,
735
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
736
            'disable_notification' => (bool)$disableNotification,
737
        ]));
738
    }
739
740
    /**
741
     * Use this method to send general files. On success, the sent Message is returned.
@@ 754-768 (lines=15) @@
751
     * @throws \TelegramBot\Api\InvalidArgumentException
752
     * @throws \TelegramBot\Api\Exception
753
     */
754
    public function sendDocument(
755
        $chatId,
756
        $document,
757
        $replyToMessageId = null,
758
        $replyMarkup = null,
759
        $disableNotification = false
760
    ) {
761
        return Message::fromResponse($this->call('sendDocument', [
762
            'chat_id' => $chatId,
763
            'document' => $document,
764
            'reply_to_message_id' => $replyToMessageId,
765
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
766
            'disable_notification' => (bool)$disableNotification,
767
        ]));
768
    }
769
770
    /**
771
     * Use this method to get basic info about a file and prepare it for downloading.
@@ 915-931 (lines=17) @@
912
     * @throws \TelegramBot\Api\InvalidArgumentException
913
     * @throws \TelegramBot\Api\Exception
914
     */
915
    public function editMessageText(
916
        $chatId,
917
        $messageId,
918
        $text,
919
        $parseMode = null,
920
        $disablePreview = false,
921
        $replyMarkup = null
922
    ) {
923
        return Message::fromResponse($this->call('editMessageText', [
924
            'chat_id' => $chatId,
925
            'message_id' => $messageId,
926
            'text' => $text,
927
            'parse_mode' => $parseMode,
928
            'disable_web_page_preview' => $disablePreview,
929
            'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
930
        ]));
931
    }
932
933
    /**
934
     * Use this method to edit text messages sent by the bot or via the bot