Longman\TelegramBot\Entities\Keyboard::parseButton PHP Method

parseButton() protected method

Parse a given button to the correct KeyboardButton object type.
protected parseButton ( array | string | KeyboardButton $button ) : KeyboardButton | null
$button array | string | KeyboardButton
return KeyboardButton | null
    protected function parseButton($button)
    {
        $button_class = $this->getKeyboardButtonClass();
        if ($button instanceof $button_class) {
            return $button;
        }
        if (!$this->isInlineKeyboard() || $button_class::couldBe($button)) {
            return new $button_class($button);
        }
        return null;
    }