This repository was archived by the owner on Sep 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +28
-13
lines changed Expand file tree Collapse file tree 4 files changed +28
-13
lines changed Original file line number Diff line number Diff line change @@ -77,4 +77,27 @@ final public function export(): array
7777
7878 return $ finalArray ;
7979 }
80+
81+ /**
82+ * Will resolve the dependency of a mandatory inline_message_id OR a chat_id + message_id
83+ *
84+ * NOTE: This will use pass by reference instead of copy on write as the use-case for this functions allows this
85+ *
86+ * @param array $return
87+ * @return array
88+ */
89+ final protected function mandatoryUserOrInlineMessageId (array &$ return ): array
90+ {
91+ if (empty ($ this ->chat_id ) && empty ($ this ->message_id )) {
92+ $ return [] = 'inline_message_id ' ;
93+ }
94+
95+ // On the other hand, chat_id and message_id are mandatory if inline_message_id is not filled in
96+ if (empty ($ this ->inline_message_id )) {
97+ $ return [] = 'chat_id ' ;
98+ $ return [] = 'message_id ' ;
99+ }
100+
101+ return $ return ;
102+ }
80103}
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ class EditMessageCaption extends TelegramMethods
5050
5151 public function getMandatoryFields (): array
5252 {
53- return [];
53+ $ returnValue = [];
54+ return $ this ->mandatoryUserOrInlineMessageId ($ returnValue );
5455 }
5556}
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ class EditMessageReplyMarkup extends TelegramMethods
4444
4545 public function getMandatoryFields (): array
4646 {
47- return [];
47+ $ returnValue = [];
48+ return $ this ->mandatoryUserOrInlineMessageId ($ returnValue );
4849 }
4950}
Original file line number Diff line number Diff line change @@ -64,17 +64,7 @@ class EditMessageText extends TelegramMethods
6464 public function getMandatoryFields (): array
6565 {
6666 $ returnValue [] = 'text ' ;
67- // Inline_message_id is mandatory if no chat_id and message_id are filled in
68- if (empty ($ this ->chat_id ) && empty ($ this ->message_id )) {
69- $ returnValue [] = 'inline_message_id ' ;
70- }
71-
72- // On the other hand, chat_id and message_id are mandatory if inline_message_id is not filled in
73- if (empty ($ this ->inline_message_id )) {
74- $ returnValue [] = 'chat_id ' ;
75- $ returnValue [] = 'message_id ' ;
76- }
77-
67+ $ this ->mandatoryUserOrInlineMessageId ($ returnValue );
7868 return $ returnValue ;
7969 }
8070}
You can’t perform that action at this time.
0 commit comments