From ed8f3e43e1886b17e405f6c89cc932050a2b9139 Mon Sep 17 00:00:00 2001 From: Netkas Date: Sun, 12 Feb 2023 18:33:40 -0500 Subject: [PATCH] Added \TgBotLib\Objects > WebAppData --- src/TgBotLib/Objects/WebAppData.php | 68 +++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/TgBotLib/Objects/WebAppData.php diff --git a/src/TgBotLib/Objects/WebAppData.php b/src/TgBotLib/Objects/WebAppData.php new file mode 100644 index 0000000..aea4dd1 --- /dev/null +++ b/src/TgBotLib/Objects/WebAppData.php @@ -0,0 +1,68 @@ +data; + } + + /** + * Text of the web_app keyboard button from which the Web App was opened. + * Be aware that a bad client can send arbitrary data in this field. + * + * @return string + */ + public function getButtonText(): string + { + return $this->button_text; + } + + /** + * Returns an array representation of the object. + * + * @return array + */ + public function toArray(): array + { + return [ + 'data' => $this->data, + 'button_text' => $this->button_text, + ]; + } + + /** + * Constructs the object from an array representation. + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->data = @$data['data'] ?: ''; + $object->button_text = @$data['button_text'] ?: ''; + + return $object; + } + } \ No newline at end of file