Code Duplication    Length = 20-24 lines in 2 locations

src/Entities/InlineKeyboard.php 2 locations

@@ 81-104 (lines=24) @@
78
     * @param $clear_keyboard Remove all the buttons from this object.
79
     * @return JSON-serialized string with the buttons.
80
     */
81
    public function get($clear_keyboard = true)
82
    {
83
84
        // Check if it is empty
85
        if (empty($this->inline_keyboard)) {
86
            throw new BotException("Inline keyboard is empty");
87
        }
88
89
        // Create a new array to put our buttons
90
        $reply_markup = ['inline_keyboard' => $this->inline_keyboard];
91
92
        // Encode the array in a json object
93
        $reply_markup = json_encode($reply_markup);
94
95
        if ($clear_keyboard) {
96
            $this->clearKeyboard();
97
        }
98
99
        return $reply_markup;
100
    }
101
102
    /**
103
     * \brief Get the array containing the buttons. (Use this method when adding keyboard to inline query results)
104
     * @param $clean_keyboard Remove all the button from this object.
105
     * @return An array containing the buttons.
106
     */
107
    public function getArray($clean_keyboard = true)
@@ 107-126 (lines=20) @@
104
     * @param $clean_keyboard Remove all the button from this object.
105
     * @return An array containing the buttons.
106
     */
107
    public function getArray($clean_keyboard = true)
108
    {
109
110
        // Check if it is empty
111
        if (empty($this->inline_keyboard)) {
112
            throw new BotException("Inline keyboard is empty");
113
        }
114
115
        // Create a new array to put the buttons
116
        $reply_markup = ['inline_keyboard' => $this->inline_keyboard];
117
118
        if ($clean_keyboard) {
119
            $this->clearKeyboard();
120
        }
121
122
        return $reply_markup;
123
    }
124
125
    /** \brief Add buttons for the current row of buttons
126
     * \details Each array sent as parameter require a text key
127
     * and one another key (as specified <a href="https://core.telegram.org/bots/api/#inlinekeyboardbutton" target="blank">here</a> between:
128
     * - url
129
     * - callback_data