Code Duplication    Length = 20-24 lines in 2 locations

src/Entities/InlineKeyboard.php 2 locations

@@ 68-91 (lines=24) @@
65
     * @param bool $clear_keyboard Remove all the buttons from this object.
66
     * @return string JSON object.
67
     */
68
    public function get(bool $clear_keyboard = true) : string
69
    {
70
        if (empty($this->inline_keyboard)) {
71
            throw new BotException("Inline keyboard is empty");
72
        }
73
74
        // Create a new array to put our buttons
75
        $reply_markup = ['inline_keyboard' => $this->inline_keyboard];
76
        $reply_markup = json_encode($reply_markup);
77
78
        if ($clear_keyboard) {
79
            $this->clearKeyboard();
80
        }
81
82
        return $reply_markup;
83
    }
84
85
    /**
86
     * \brief Get the array containing the buttons.
87
     * \details Use this method when adding keyboard to inline query results.
88
     * @param bool $clean_keyboard If it's true, it'll clean the inline keyboard.
89
     * @return array An array containing the buttons.
90
     */
91
    public function getArray(bool $clean_keyboard = true) : array
92
    {
93
        if (empty($this->inline_keyboard)) {
94
            throw new BotException("Inline keyboard is empty");
@@ 91-110 (lines=20) @@
88
     * @param bool $clean_keyboard If it's true, it'll clean the inline keyboard.
89
     * @return array An array containing the buttons.
90
     */
91
    public function getArray(bool $clean_keyboard = true) : array
92
    {
93
        if (empty($this->inline_keyboard)) {
94
            throw new BotException("Inline keyboard is empty");
95
        }
96
97
        // Create a new array to put the buttons
98
        $reply_markup = ['inline_keyboard' => $this->inline_keyboard];
99
100
        if ($clean_keyboard) {
101
            $this->clearKeyboard();
102
        }
103
104
        return $reply_markup;
105
    }
106
107
    /**
108
     * \brief Add buttons for the current row.
109
     * \details Each array sent as parameter requires a text key
110
     * and one another key
111
     * (see <a href="https://core.telegram.org/bots/api/#inlinekeyboardbutton" target="blank">here</a>)
112
     * like:
113
     * - url