Code Duplication    Length = 19-20 lines in 2 locations

src/CoreBot.php 2 locations

@@ 776-795 (lines=20) @@
773
     * $results Array on InlineQueryResult (https://core.telegram.org/bots/api#inlinequeryresult)
774
     * $switch_pm_text Text to show on the button
775
     */
776
    public function answerInlineQuerySwitchPM($results, $switch_pm_text, $switch_pm_parameter = '', $is_personal = true, $cache_time = 300) {
777
778
        if (!isset($this->_inline_query_id)) {
779
780
            throw new BotException("Inline query id not set, wrong update");
781
782
        }
783
784
        $parameters = [
785
            'inline_query_id' => $this->_inline_query_id,
786
            'switch_pm_text' => $switch_pm_text,
787
            'is_personal' => $is_personal,
788
            'switch_pm_parameter' => $switch_pm_parameter,
789
            'results' => $results,
790
            'cache_time' => $cache_time
791
        ];
792
793
        return $this->exec_curl_request($this->_api_url . 'answerInlineQuery?' . http_build_query($parameters));
794
795
    }
796
797
    /*
798
     * Answer a inline query (when the user write @botusername "Query") with a button, that will make user switch to the private chat with the bot, on the top of the results (https://core.telegram.org/bots/api#answerinlinequery)
@@ 803-821 (lines=19) @@
800
     * @param
801
     * $switch_pm_text Text to show on the button
802
     */
803
    public function answerEmptyInlineQuerySwitchPM($switch_pm_text, $switch_pm_parameter = '', $is_personal = true, $cache_time = 300) {
804
805
        if (!isset($this->_inline_query_id)) {
806
807
            throw new BotException("Inline query id not set, wrong update");
808
809
        }
810
811
        $parameters = [
812
            'inline_query_id' => $this->_inline_query_id,
813
            'switch_pm_text' => $switch_pm_text,
814
            'is_personal' => $is_personal,
815
            'switch_pm_parameter' => $switch_pm_parameter,
816
            'cache_time' => $cache_time
817
        ];
818
819
        return $this->exec_curl_request($this->_api_url . 'answerInlineQuery?' . http_build_query($parameters));
820
821
    }
822
823
    /**
824
     * \brief Exec any api request using this method.