Refactor event type determination logic
This commit is contained in:
parent
4829853d0e
commit
56c7fb04d2
4 changed files with 159 additions and 123 deletions
|
@ -52,125 +52,4 @@
|
|||
|
||||
return self::$currencies_cache[strtolower($code)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the type of event based on the provided update object.
|
||||
*
|
||||
* @param Update $update The update object containing event information.
|
||||
* @return UpdateEventType The determined type of the event.
|
||||
*/
|
||||
public static function determineEventType(Update $update): UpdateEventType
|
||||
{
|
||||
if($update->getRemovedChatBoost() !== null)
|
||||
{
|
||||
return UpdateEventType::REMOVED_CHAT_BOOST_EVENT;
|
||||
}
|
||||
|
||||
if($update->getChatBoost() !== null)
|
||||
{
|
||||
return UpdateEventType::CHAT_BOOST_EVENT;
|
||||
}
|
||||
|
||||
if($update->getChatJoinRequest() !== null)
|
||||
{
|
||||
return UpdateEventType::CHAT_JOIN_REQUEST_EVENT;
|
||||
}
|
||||
|
||||
if($update->getChatMember() !== null)
|
||||
{
|
||||
return UpdateEventType::CHAT_MEMBER_UPDATED;
|
||||
}
|
||||
|
||||
if($update->getMyChatMember() !== null)
|
||||
{
|
||||
return UpdateEventType::MY_CHAT_MEMBER_UPDATED;
|
||||
}
|
||||
|
||||
if($update->getPollAnswer() !== null)
|
||||
{
|
||||
return UpdateEventType::POLL_ANSWER;
|
||||
}
|
||||
|
||||
if($update->getPoll() !== null)
|
||||
{
|
||||
return UpdateEventType::POLL;
|
||||
}
|
||||
|
||||
if($update->getPurchasedPaidMedia() !== null)
|
||||
{
|
||||
return UpdateEventType::PAID_MEDIA_PURCHASED;
|
||||
}
|
||||
|
||||
if($update->getPreCheckoutQuery() !== null)
|
||||
{
|
||||
return UpdateEventType::PRE_CHECKOUT_QUERY;
|
||||
}
|
||||
|
||||
if($update->getPreCheckoutQuery() !== null)
|
||||
{
|
||||
return UpdateEventType::PRE_CHECKOUT_QUERY;
|
||||
}
|
||||
|
||||
if($update->getCallbackQuery() !== null)
|
||||
{
|
||||
return UpdateEventType::CALLBACK_QUERY;
|
||||
}
|
||||
|
||||
if($update->getChosenInlineResult() !== null)
|
||||
{
|
||||
return UpdateEventType::CHOSEN_INLINE_RESULT;
|
||||
}
|
||||
|
||||
if($update->getInlineQuery() !== null)
|
||||
{
|
||||
return UpdateEventType::INLINE_QUERY;
|
||||
}
|
||||
|
||||
if($update->getMessageReactionCount() !== null)
|
||||
{
|
||||
return UpdateEventType::MESSAGE_REACTION_COUNT;
|
||||
}
|
||||
|
||||
if($update->getMessageReaction() !== null)
|
||||
{
|
||||
return UpdateEventType::MESSAGE_REACTION;
|
||||
}
|
||||
|
||||
if($update->getDeletedBusinessMessages() !== null)
|
||||
{
|
||||
return UpdateEventType::DELETED_BUSINESS_MESSAGES;
|
||||
}
|
||||
|
||||
if($update->getEditedBusinessMessage() !== null)
|
||||
{
|
||||
return UpdateEventType::EDITED_BUSINESS_MESSAGE;
|
||||
}
|
||||
|
||||
if($update->getBusinessMessage() !== null)
|
||||
{
|
||||
return UpdateEventType::BUSINESS_MESSAGE;
|
||||
}
|
||||
|
||||
if($update->getBusinessConnection() !== null)
|
||||
{
|
||||
return UpdateEventType::BUSINESS_CONNECTION;
|
||||
}
|
||||
|
||||
if($update->getEditedChannelPost() !== null)
|
||||
{
|
||||
return UpdateEventType::EDITED_CHANNEL_POST;
|
||||
}
|
||||
|
||||
if($update->getChannelPost() !== null)
|
||||
{
|
||||
return UpdateEventType::CHANNEL_POST;
|
||||
}
|
||||
|
||||
if($update->getEditedMessage() !== null)
|
||||
{
|
||||
return UpdateEventType::EDITED_MESSAGE;
|
||||
}
|
||||
|
||||
return UpdateEventType::UPDATE_EVENT;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue