From 72d708e61f53d115cdbd55ad81e8d8b6827fba13 Mon Sep 17 00:00:00 2001 From: Mateo O Date: Fri, 11 Aug 2023 22:29:12 -0500 Subject: [PATCH] deprecated button class --- src/Buttons.php | 155 ++++++++++++++++++++++++------------------------ 1 file changed, 79 insertions(+), 76 deletions(-) diff --git a/src/Buttons.php b/src/Buttons.php index 756a3df..739407a 100644 --- a/src/Buttons.php +++ b/src/Buttons.php @@ -1,4 +1,4 @@ -type = $type; + private function __construct(string $type, array $others_params) + { + $this->type = $type; - if (!empty($others_params)) { - foreach ($others_params as $i => $value) { - $this->button[$i] = $value; - } + if (!empty($others_params)) { + foreach ($others_params as $i => $value) { + $this->button[$i] = $value; } } + } - /** - * @param string $type inline_keyboard, keyboard - * @param array $others_params - * @return Buttons - */ - public static function create(string $type = 'inline_keyboard', array $others_params = []): Buttons - { - return new self($type, $others_params); - } + /** + * @param string $type inline_keyboard, keyboard + * @param array $others_params + * @return Buttons + */ + public static function create(string $type = 'inline_keyboard', array $others_params = []): Buttons + { + return new self($type, $others_params); + } - /** - * remove reply keyboard - */ - public static function replyKeyboardRemove(bool $selective = false): Buttons - { - return new self('', [ - 'remove_keyboard' => true, - 'selective' => $selective - ]); - } + /** + * remove reply keyboard + */ + public static function replyKeyboardRemove(bool $selective = false): Buttons + { + return new self('', [ + 'remove_keyboard' => true, + 'selective' => $selective + ]); + } - /** - * Add new line to the button - */ - public function AddLine(): Buttons - { - $this->line++; - return $this; - } + /** + * Add new line to the button + */ + public function AddLine(): Buttons + { + $this->line++; + return $this; + } - /** - * Add new ceil - */ - public function addCeil(array $params): Buttons - { - $this->button[$this->type][$this->line][] = $params; - return $this; - } + /** + * Add new ceil + */ + public function addCeil(array $params): Buttons + { + $this->button[$this->type][$this->line][] = $params; + return $this; + } - /** - * add new keyboard ceil - */ - public function addKeyboard( - string $text, - bool $request_contact = false, - bool $request_location = false, - mixed $request_poll = null, - object $web_app = null - ): Buttons - { - $payload = [ - 'text' => $text, - 'request_contact' => $request_contact, - 'request_location' => $request_location, - 'request_poll' => $request_poll, - 'web_app' => $web_app - ]; + /** + * add new keyboard ceil + */ + public function addKeyboard( + string $text, + bool $request_contact = false, + bool $request_location = false, + mixed $request_poll = null, + object $web_app = null + ): Buttons { + $payload = [ + 'text' => $text, + 'request_contact' => $request_contact, + 'request_location' => $request_location, + 'request_poll' => $request_poll, + 'web_app' => $web_app + ]; - Arrays::DeleteEmptyKeys($payload); - $this->button[$this->type][$this->line][] = $payload; - return $this; - } + Arrays::DeleteEmptyKeys($payload); + $this->button[$this->type][$this->line][] = $payload; + return $this; + } - public function __toString(): string - { - return json_encode($this->button); - } - - public function get(): array - { - return $this->button; - } + public function __toString(): string + { + return json_encode($this->button); + } + + public function get(): array + { + return $this->button; + } }