| Total Complexity | 46 |
| Total Lines | 610 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like request often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use request, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 13 | class request {
|
||
| 14 | private const METHODS_ACTION = [ |
||
| 15 | 'getupdates' => 'getUpdates', |
||
| 16 | 'getup' => 'getUpdates', |
||
| 17 | 'updates' => 'getUpdates', |
||
| 18 | 'setwebhook' => 'setWebhook', |
||
| 19 | 'setweb' => 'setWebhook', |
||
| 20 | 'webhook' => 'setWebhook', |
||
| 21 | 'deletewebhook' => 'deleteWebhook', |
||
| 22 | 'deleteweb' => 'deleteWebhook', |
||
| 23 | 'delweb' => 'deleteWebhook', |
||
| 24 | 'getwebhookinfo' => 'getWebhookInfo', |
||
| 25 | 'getweb' => 'getWebhookInfo', |
||
| 26 | 'getme' => 'getMe', |
||
| 27 | 'me' => 'getMe', |
||
| 28 | 'logout' => 'logOut', |
||
| 29 | 'close' => 'close', |
||
| 30 | 'sendmessage' => 'sendMessage', |
||
| 31 | 'send' => 'sendMessage', |
||
| 32 | 'forwardmessage' => 'forwardMessage', |
||
| 33 | 'forward' => 'forwardMessage', |
||
| 34 | 'copymessage' => 'copyMessage', |
||
| 35 | 'copy' => 'copyMessage', |
||
| 36 | 'sendphoto' => 'sendPhoto', |
||
| 37 | 'photo' => 'sendPhoto', |
||
| 38 | 'sendaudio' => 'sendAudio', |
||
| 39 | 'audio' => 'sendAudio', |
||
| 40 | 'senddocument' => 'sendDocument', |
||
| 41 | 'senddoc' => 'sendDocument', |
||
| 42 | 'document' => 'sendDocument', |
||
| 43 | 'doc' => 'sendDocument', |
||
| 44 | 'sendvideo' => 'sendVideo', |
||
| 45 | 'video' => 'sendVideo', |
||
| 46 | 'sendanimation' => 'sendAnimation', |
||
| 47 | 'animation' => 'sendAnimation', |
||
| 48 | 'sendgif' => 'sendAnimation', |
||
| 49 | 'gif' => 'sendAnimation', |
||
| 50 | 'sendvoice' => 'sendVoice', |
||
| 51 | 'voice' => 'sendVoice', |
||
| 52 | 'sendvideonote' => 'sendVideoNote', |
||
| 53 | 'videonote' => 'sendVideoNote', |
||
| 54 | 'sendmediagroup' => 'sendMediaGroup', |
||
| 55 | 'mediagroup' => 'sendMediaGroup', |
||
| 56 | 'media' => 'sendMediaGroup', |
||
| 57 | 'sendlocation' => 'sendLocation', |
||
| 58 | 'sendloc' => 'sendLocation', |
||
| 59 | 'location' => 'sendLocation', |
||
| 60 | 'loc' => 'sendLocation', |
||
| 61 | 'editmessagelivelocation' => 'editMessageLiveLocation', |
||
| 62 | 'editliveloc' => 'editMessageLiveLocation', |
||
| 63 | 'stopmessagelivelocation' => 'stopMessageLiveLocation', |
||
| 64 | 'stopliveloc' => 'stopMessageLiveLocation', |
||
| 65 | 'sendvenue' => 'sendVenue', |
||
| 66 | 'venue' => 'sendVenue', |
||
| 67 | 'sendcontact' => 'sendContact', |
||
| 68 | 'contact' => 'sendContact', |
||
| 69 | 'sendpoll' => 'sendPoll', |
||
| 70 | 'poll' => 'sendPoll', |
||
| 71 | 'senddice' => 'sendDice', |
||
| 72 | 'dice' => 'sendDice', |
||
| 73 | 'sendchataction' => 'sendChatAction', |
||
| 74 | 'chataction' => 'sendChatAction', |
||
| 75 | 'action' => 'sendChatAction', |
||
| 76 | 'getuserprofilephotos' => 'getUserProfilePhotos', |
||
| 77 | 'userphotos' => 'getUserProfilePhotos', |
||
| 78 | 'getfile' => 'getFile', |
||
| 79 | 'file' => 'getFile', |
||
| 80 | 'banchatmember' => 'banChatMember', |
||
| 81 | 'ban' => 'banChatMember', |
||
| 82 | 'kickchatmember' => 'banChatMember', |
||
| 83 | 'kick' => 'unbanChatMember', |
||
| 84 | 'unbanchatmember' => 'unbanChatMember', |
||
| 85 | 'unban' => 'unbanChatMember', |
||
| 86 | 'restrictchatmember' => 'restrictChatMember', |
||
| 87 | 'restrict' => 'restrictChatMember', |
||
| 88 | 'promotechatmember' => 'promoteChatMember', |
||
| 89 | 'promote' => 'promoteChatMember', |
||
| 90 | 'setchatadministratorcustomtitle' => 'setChatAdministratorCustomTitle', |
||
| 91 | 'customtitle' => 'setChatAdministratorCustomTitle', |
||
| 92 | 'banchatsenderchat' => 'banChatSenderChat', |
||
| 93 | 'bansender' => 'banChatSenderChat', |
||
| 94 | 'unbanchatsenderchat' => 'unbanChatSenderChat', |
||
| 95 | 'unbansender' => 'unbanChatSenderChat', |
||
| 96 | 'setchatpermissions' => 'setChatPermissions', |
||
| 97 | 'permissions' => 'setChatPermissions', |
||
| 98 | 'exportchatinvitelink' => 'exportChatInviteLink', |
||
| 99 | 'link' => 'exportChatInviteLink', |
||
| 100 | 'createchatinvitelink' => 'createChatInviteLink', |
||
| 101 | 'crlink' => 'createChatInviteLink', |
||
| 102 | 'editchatinvitelink' => 'editChatInviteLink', |
||
| 103 | 'edlink' => 'editChatInviteLink', |
||
| 104 | 'revokechatinvitelink' => 'revokeChatInviteLink', |
||
| 105 | 'relink' => 'revokeChatInviteLink', |
||
| 106 | 'approvechatjoinrequest' => 'approveChatJoinRequest', |
||
| 107 | 'acceptjoin' => 'approveChatJoinRequest', |
||
| 108 | 'declinechatjoinrequest' => 'declineChatJoinRequest', |
||
| 109 | 'denyjoin' => 'declineChatJoinRequest', |
||
| 110 | 'setchatphoto' => 'setChatPhoto', |
||
| 111 | 'deletechatphoto' => 'deleteChatPhoto', |
||
| 112 | 'setchattitle' => 'setChatTitle', |
||
| 113 | 'title' => 'setChatTitle', |
||
| 114 | 'setchatdescription' => 'setChatDescription', |
||
| 115 | 'description' => 'setChatDescription', |
||
| 116 | 'pinchatmessage' => 'pinChatMessage', |
||
| 117 | 'pin' => 'pinChatMessage', |
||
| 118 | 'unpinchatmessage' => 'unpinChatMessage', |
||
| 119 | 'unpin' => 'unpinChatMessage', |
||
| 120 | 'unpinallchatmessages' => 'unpinAllChatMessages', |
||
| 121 | 'unpinall' => 'unpinAllChatMessages', |
||
| 122 | 'leavechat' => 'leaveChat', |
||
| 123 | 'leave' => 'leaveChat', |
||
| 124 | 'getchat' => 'getChat', |
||
| 125 | 'chat' => 'getChat', |
||
| 126 | 'getchatadministrators' => 'getChatAdministrators', |
||
| 127 | 'admins' => 'getChatAdministrators', |
||
| 128 | 'getchatmembercount' => 'getChatMemberCount', |
||
| 129 | 'getchatmemberscount' => 'getChatMemberCount', |
||
| 130 | 'memberscount' => 'getChatMemberCount', |
||
| 131 | 'getchatmember' => 'getChatMember', |
||
| 132 | 'member' => 'getChatMember', |
||
| 133 | 'setchatstickerset' => 'setChatStickerSet', |
||
| 134 | 'setsticker' => 'setChatStickerSet', |
||
| 135 | 'deletechatstickerset' => 'deleteChatStickerSet', |
||
| 136 | 'delsticker' => 'deleteChatStickerSet', |
||
| 137 | 'answercallbackquery' => 'answerCallbackQuery', |
||
| 138 | 'answer' => 'answerCallbackQuery', |
||
| 139 | 'setmycommands' => 'setMyCommands', |
||
| 140 | 'setcommands' => 'setMyCommands', |
||
| 141 | 'deletemycommands' => 'deleteMyCommands', |
||
| 142 | 'deletecommands' => 'deleteMyCommands', |
||
| 143 | 'getmycommands' => 'getMyCommands', |
||
| 144 | 'getcommands' => 'getMyCommands', |
||
| 145 | 'setchatmenubutton' => 'setChatMenuButton', |
||
| 146 | 'setmenubutton' => 'setChatMenuButton', |
||
| 147 | 'setmenu' => 'setChatMenuButton', |
||
| 148 | 'setbutton' => 'setChatMenuButton', |
||
| 149 | 'getchatmenubutton' => 'getChatMenuButton', |
||
| 150 | 'getmenubutton' => 'getChatMenuButton', |
||
| 151 | 'getmenu' => 'getChatMenuButton', |
||
| 152 | 'getbutton' => 'getChatMenuButton', |
||
| 153 | 'setmydefaultadministratorrights' => 'setMyDefaultAdministratorRights', |
||
| 154 | 'setmydefaultadminrights' => 'setMyDefaultAdministratorRights', |
||
| 155 | 'setmydefaultrights' => 'setMyDefaultAdministratorRights', |
||
| 156 | 'setdefaultrights' => 'setMyDefaultAdministratorRights', |
||
| 157 | 'getmydefaultadministratorrights' => 'getMyDefaultAdministratorRights', |
||
| 158 | 'getmydefaultadminrights' => 'getMyDefaultAdministratorRights', |
||
| 159 | 'getmydefaultrights' => 'getMyDefaultAdministratorRights', |
||
| 160 | 'getdefaultrights' => 'getMyDefaultAdministratorRights', |
||
| 161 | 'editmessagetext' => 'editMessageText', |
||
| 162 | 'edittext' => 'editMessageText', |
||
| 163 | 'editmessagecaption' => 'editMessageCaption', |
||
| 164 | 'editcap' => 'editMessageCaption', |
||
| 165 | 'editcaption' => 'editMessageCaption', |
||
| 166 | 'editmessagemedia' => 'editMessageMedia', |
||
| 167 | 'editmedia' => 'editMessageMedia', |
||
| 168 | 'editmessagereplymarkup' => 'editMessageReplyMarkup', |
||
| 169 | 'editreply' => 'editMessageReplyMarkup', |
||
| 170 | 'editkeyboard' => 'editMessageReplyMarkup', |
||
| 171 | 'stoppoll' => 'stopPoll', |
||
| 172 | 'deletemessage' => 'deleteMessage', |
||
| 173 | 'del' => 'deleteMessage', |
||
| 174 | 'sendsticker' => 'sendSticker', |
||
| 175 | 'sticker' => 'sendSticker', |
||
| 176 | 'getstickerset' => 'getStickerSet', |
||
| 177 | 'uploadstickerfile' => 'uploadStickerFile', |
||
| 178 | 'uploadsticker' => 'uploadStickerFile', |
||
| 179 | 'createnewstickerset' => 'createNewStickerSet', |
||
| 180 | 'createsticker' => 'createNewStickerSet', |
||
| 181 | 'addstickertoset' => 'addStickerToSet', |
||
| 182 | 'addsticker' => 'addStickerToSet', |
||
| 183 | 'setstickerpositioninset' => 'setStickerPositionInSet', |
||
| 184 | 'setstickerposition' => 'setStickerPositionInSet', |
||
| 185 | 'setstickerpos' => 'setStickerPositionInSet', |
||
| 186 | 'deletestickerfromset' => 'deleteStickerFromSet', |
||
| 187 | 'deletesticker' => 'deleteStickerFromSet', |
||
| 188 | 'setstickersetthumb' => 'setStickerSetThumb', |
||
| 189 | 'setstickerthumb' => 'setStickerSetThumb', |
||
| 190 | 'answerinlinequery' => 'answerInlineQuery', |
||
| 191 | 'answerinline' => 'answerInlineQuery', |
||
| 192 | 'answerwebappquery' => 'answerWebAppQuery', |
||
| 193 | 'answerwebapp' => 'answerWebAppQuery', |
||
| 194 | 'answerweb' => 'answerWebAppQuery', |
||
| 195 | 'sendinvoice' => 'sendInvoice', |
||
| 196 | 'invoice' => 'sendInvoice', |
||
| 197 | 'createinvoicelink' => 'createInvoiceLink', |
||
| 198 | 'createinvoice' => 'sendInvoice', |
||
| 199 | 'answershippingquery' => 'answerShippingQuery', |
||
| 200 | 'answershipping' => 'answerShippingQuery', |
||
| 201 | 'answerprecheckoutquery' => 'answerPreCheckoutQuery', |
||
| 202 | 'answerprecheckout' => 'answerPreCheckoutQuery', |
||
| 203 | 'answerprecheck' => 'answerPreCheckoutQuery', |
||
| 204 | 'setpassportdataerrors' => 'setPassportDataErrors', |
||
| 205 | 'setpassport' => 'setPassportDataErrors', |
||
| 206 | 'sendgame' => 'sendGame', |
||
| 207 | 'game' => 'sendGame', |
||
| 208 | 'setgamescore' => 'setGameScore', |
||
| 209 | 'gamescore' => 'setGameScore', |
||
| 210 | 'getgamehighscores' => 'getGameHighScores', |
||
| 211 | 'getgamehigh' => 'getGameHighScores' |
||
| 212 | ]; |
||
| 213 | |||
| 214 | private const METHODS_KEYS = [ |
||
| 215 | 'getUpdates' => ['offset','limit','timeout','allowed_updates','token','return_array','forgot','answer'], |
||
| 216 | 'setWebhook' => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','return_array','forgot','answer'], |
||
| 217 | 'deleteWebhook' => ['drop_pending_updates','token','return_array','forgot','answer'], |
||
| 218 | 'getWebhookInfo' => ['token','return_array','forgot','answer'], |
||
| 219 | 'getMe' => ['token','return_array','forgot','answer'], |
||
| 220 | 'logOut' => ['token','return_array','forgot','answer'], |
||
| 221 | 'close' => ['token','return_array','forgot','answer'], |
||
| 222 | 'sendMessage' => ['text','chat_id','parse_mode','entities','disable_web_page_preview','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 223 | 'forwardMessage' => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','return_array','forgot','answer'], |
||
| 224 | 'copyMessage' => ['chat_id','from_chat_id','message_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 225 | 'sendPhoto' => ['photo','chat_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 226 | 'sendAudio' => ['audio','chat_id','caption','parse_mode','caption_entities','duration','performer','title','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 227 | 'sendDocument' => ['document','chat_id','thumb','caption','parse_mode','caption_entities','disable_content_type_detection','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 228 | 'sendVideo' => ['video','chat_id','duration','width','height','thumb','caption','parse_mode','caption_entities','supports_streaming','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 229 | 'sendAnimation' => ['animation','chat_id','duration','width','height','thumb','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 230 | 'sendVoice' => ['voice','chat_id','caption','parse_mode','caption_entities','duration','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 231 | 'sendVideoNote' => ['video_note','chat_id','duration','length','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 232 | 'sendMediaGroup' => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','return_array','forgot','answer'], |
||
| 233 | 'sendLocation' => ['latitude','longitude','chat_id','horizontal_accuracy','live_period','heading','proximity_alert_radius','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 234 | 'editMessageLiveLocation' => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','return_array','forgot','answer'], |
||
| 235 | 'stopMessageLiveLocation' => ['chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
||
| 236 | 'sendVenue' => ['chat_id','latitude','longitude','title','address','foursquare_id','foursquare_type','google_place_id','google_place_type','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 237 | 'sendContact' => ['phone_number','first_name','chat_id','last_name','vcard','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 238 | 'sendPoll' => ['question','options','chat_id','is_anonymous','type','allows_multiple_answers','correct_option_id','explanation','explanation_parse_mode','explanation_entities','open_period','close_date','is_closed','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 239 | 'sendDice' => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 240 | 'sendChatAction' => ['chat_id','action','token','return_array','forgot','answer'], |
||
| 241 | 'getUserProfilePhotos' => ['user_id','offset','limit','token','return_array','forgot','answer'], |
||
| 242 | 'getFile' => ['file_id','token','return_array','forgot','answer'], |
||
| 243 | 'banChatMember' => ['chat_id','user_id','until_date','revoke_messages','token','return_array','forgot','answer'], |
||
| 244 | 'unbanChatMember' => ['chat_id','user_id','only_if_banned','token','return_array','forgot','answer'], |
||
| 245 | 'restrictChatMember' => ['permissions','chat_id','user_id','until_date','token','return_array','forgot','answer'], |
||
| 246 | 'promoteChatMember' => ['chat_id','user_id','is_anonymous','can_manage_chat','can_post_messages','can_edit_messages','can_delete_messages','can_manage_video_chats','can_restrict_members','can_promote_members','can_change_info','can_invite_users','can_pin_messages','token','return_array','forgot','answer'], |
||
| 247 | 'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','return_array','forgot','answer'], |
||
| 248 | 'banChatSenderChat' => ['sender_chat_id','chat_id','token','return_array','forgot','answer'], |
||
| 249 | 'unbanChatSenderChat' => ['sender_chat_id','chat_id','token','return_array','forgot','answer'], |
||
| 250 | 'setChatPermissions' => ['permissions','chat_id','token','return_array','forgot','answer'], |
||
| 251 | 'exportChatInviteLink' => ['chat_id','token','return_array','forgot','answer'], |
||
| 252 | 'createChatInviteLink' => ['chat_id','name','expire_date','member_limit','creates_join_request','token','return_array','forgot','answer'], |
||
| 253 | 'editChatInviteLink' => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','return_array','forgot','answer'], |
||
| 254 | 'revokeChatInviteLink' => ['invite_link','chat_id','token','return_array','forgot','answer'], |
||
| 255 | 'approveChatJoinRequest' => ['chat_id','user_id','token','return_array','forgot','answer'], |
||
| 256 | 'declineChatJoinRequest' => ['chat_id','user_id','token','return_array','forgot','answer'], |
||
| 257 | 'setChatPhoto' => ['photo','chat_id','token','return_array','forgot','answer'], |
||
| 258 | 'deleteChatPhoto' => ['chat_id','token','return_array','forgot','answer'], |
||
| 259 | 'setChatTitle' => ['title','chat_id','token','return_array','forgot','answer'], |
||
| 260 | 'setChatDescription' => ['chat_id','description','token','return_array','forgot','answer'], |
||
| 261 | 'pinChatMessage' => ['message_id','chat_id','disable_notification','token','return_array','forgot','answer'], |
||
| 262 | 'unpinChatMessage' => ['chat_id','message_id','token','return_array','forgot','answer'], |
||
| 263 | 'unpinAllChatMessages' => ['chat_id','token','return_array','forgot','answer'], |
||
| 264 | 'leaveChat' => ['chat_id','token','return_array','forgot','answer'], |
||
| 265 | 'getChat' => ['chat_id','token','return_array','forgot','answer'], |
||
| 266 | 'getChatAdministrators' => ['chat_id','token','return_array','forgot','answer'], |
||
| 267 | 'getChatMemberCount' => ['chat_id','token','return_array','forgot','answer'], |
||
| 268 | 'getChatMember' => ['chat_id','user_id','token','return_array','forgot','answer'], |
||
| 269 | 'setChatStickerSet' => ['sticker_set_name','chat_id','token','return_array','forgot','answer'], |
||
| 270 | 'deleteChatStickerSet' => ['chat_id','token','return_array','forgot','answer'], |
||
| 271 | 'answerCallbackQuery' => ['callback_query_id','text','show_alert','url','cache_time','token','return_array','forgot','answer'], |
||
| 272 | 'setMyCommands' => ['commands','scope','language_code','token','return_array','forgot','answer'], |
||
| 273 | 'deleteMyCommands' => ['scope','language_code','token','return_array','forgot','answer'], |
||
| 274 | 'getMyCommands' => ['scope','language_code','token','return_array','forgot','answer'], |
||
| 275 | 'setChatMenuButton' => ['chat_id','menu_button','token','return_array','forgot','answer'], |
||
| 276 | 'getChatMenuButton' => ['chat_id','token','return_array','forgot','answer'], |
||
| 277 | 'setMyDefaultAdministratorRights' => ['rights','for_channels','token','return_array','forgot','answer'], |
||
| 278 | 'getMyDefaultAdministratorRights' => ['for_channels','token','return_array','forgot','answer'], |
||
| 279 | 'editMessageText' => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','return_array','forgot','answer'], |
||
| 280 | 'editMessageCaption' => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','return_array','forgot','answer'], |
||
| 281 | 'editMessageMedia' => ['media','chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
||
| 282 | 'editMessageReplyMarkup' => ['chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
||
| 283 | 'stopPoll' => ['chat_id','message_id','reply_markup','token','return_array','forgot','answer'], |
||
| 284 | 'deleteMessage' => ['chat_id','message_id','token','return_array','forgot','answer'], |
||
| 285 | 'sendSticker' => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 286 | 'getStickerSet' => ['name','token','return_array','forgot','answer'], |
||
| 287 | 'uploadStickerFile' => ['png_sticker','user_id','token','return_array','forgot','answer'], |
||
| 288 | 'createNewStickerSet' => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','contains_masks','mask_position','token','return_array','forgot','answer'], |
||
| 289 | 'addStickerToSet' => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','return_array','forgot','answer'], |
||
| 290 | 'setStickerPositionInSet' => ['sticker','position','token','return_array','forgot','answer'], |
||
| 291 | 'deleteStickerFromSet' => ['sticker','token','return_array','forgot','answer'], |
||
| 292 | 'setStickerSetThumb' => ['name','user_id','thumb','token','return_array','forgot','answer'], |
||
| 293 | 'answerInlineQuery' => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','return_array','forgot','answer'], |
||
| 294 | 'answerWebAppQuery' => ['web_app_query_id','result','token','return_array','forgot','answer'], |
||
| 295 | 'sendInvoice' => ['title','description','payload','provider_token','currency','prices','chat_id','max_tip_amount','suggested_tip_amounts','start_parameter','provider_data','photo_url','photo_size','photo_width','photo_height','need_name','need_phone_number','need_email','need_shipping_address','send_phone_number_to_provider','send_email_to_provider','is_flexible','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 296 | 'createInvoiceLink' => ['title','description','payload','provider_token','currency','prices','max_tip_amount','suggested_tip_amounts','provider_data','photo_url','photo_size','photo_width','photo_height','need_name','need_phone_number','need_email','need_shipping_address','send_phone_number_to_provider','send_email_to_provider','is_flexible','token','return_array','forgot','answer'], |
||
| 297 | 'answerShippingQuery' => ['ok','shipping_query_id','shipping_options','error_message','token','return_array','forgot','answer'], |
||
| 298 | 'answerPreCheckoutQuery' => ['ok','pre_checkout_query_id','error_message','token','return_array','forgot','answer'], |
||
| 299 | 'setPassportDataErrors' => ['errors','user_id','token','return_array','forgot','answer'], |
||
| 300 | 'sendGame' => ['game_short_name','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
||
| 301 | 'setGameScore' => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','return_array','forgot','answer'], |
||
| 302 | 'getGameHighScores' => ['user_id','chat_id','message_id','inline_message_id','token','return_array','forgot','answer'], |
||
| 303 | ]; |
||
| 304 | |||
| 305 | private const METHODS_WITH_FILE = [ |
||
| 306 | 'setWebhook' => ['certificate'], |
||
| 307 | 'sendPhoto' => ['photo'], |
||
| 308 | 'sendAudio' => ['audio', 'thumb'], |
||
| 309 | 'sendDocument' => ['document', 'thumb'], |
||
| 310 | 'sendVideo' => ['video', 'thumb'], |
||
| 311 | 'sendAnimation' => ['animation', 'thumb'], |
||
| 312 | 'sendVoice' => ['voice', 'thumb'], |
||
| 313 | 'sendVideoNote' => ['video_note', 'thumb'], |
||
| 314 | 'setChatPhoto' => ['photo'], |
||
| 315 | 'sendSticker' => ['sticker'], |
||
| 316 | 'uploadStickerFile' => ['png_sticker'], |
||
| 317 | 'createNewStickerSet' => ['png_sticker', 'tgs_sticker'], |
||
| 318 | 'addStickerToSet' => ['png_sticker', 'tgs_sticker'], |
||
| 319 | 'setStickerSetThumb' => ['thumb'], |
||
| 320 | ]; |
||
| 321 | |||
| 322 | private const METHODS_EXTRA_DEFAULTS = [ |
||
| 323 | 'getUpdates' => [], |
||
| 324 | 'setWebhook' => ['url'], |
||
| 325 | 'deleteWebhook' => [], |
||
| 326 | 'getWebhookInfo' => [], |
||
| 327 | 'getMe' => [], |
||
| 328 | 'logOut' => [], |
||
| 329 | 'close' => [], |
||
| 330 | 'sendMessage' => ['chat_id'], |
||
| 331 | 'forwardMessage' => ['from_chat_id','message_id'], |
||
| 332 | 'copyMessage' => ['from_chat_id','message_id'], |
||
| 333 | 'sendPhoto' => ['chat_id'], |
||
| 334 | 'sendAudio' => ['chat_id'], |
||
| 335 | 'sendDocument' => ['chat_id'], |
||
| 336 | 'sendVideo' => ['chat_id'], |
||
| 337 | 'sendAnimation' => ['chat_id'], |
||
| 338 | 'sendVoice' => ['chat_id'], |
||
| 339 | 'sendVideoNote' => ['chat_id'], |
||
| 340 | 'sendMediaGroup' => ['chat_id'], |
||
| 341 | 'sendLocation' => ['chat_id'], |
||
| 342 | 'editMessageLiveLocation' => [], |
||
| 343 | 'stopMessageLiveLocation' => [], |
||
| 344 | 'sendVenue' => [], |
||
| 345 | 'sendContact' => ['chat_id'], |
||
| 346 | 'sendPoll' => ['chat_id'], |
||
| 347 | 'sendDice' => ['chat_id'], |
||
| 348 | 'sendChatAction' => ['chat_id','action'], |
||
| 349 | 'getUserProfilePhotos' => ['user_id'], |
||
| 350 | 'getFile' => ['file_id'], |
||
| 351 | 'banChatMember' => ['chat_id','user_id'], |
||
| 352 | 'kickChatMember' => ['chat_id','user_id'], |
||
| 353 | 'unbanChatMember' => ['chat_id','user_id'], |
||
| 354 | 'restrictChatMember' => ['chat_id','user_id'], |
||
| 355 | 'promoteChatMember' => ['chat_id','user_id'], |
||
| 356 | 'setChatAdministratorCustomTitle' => ['chat_id','user_id'], |
||
| 357 | 'banChatSenderChat' => ['chat_id'], |
||
| 358 | 'unbanChatSenderChat' => ['chat_id'], |
||
| 359 | 'setChatPermissions' => ['chat_id'], |
||
| 360 | 'exportChatInviteLink' => ['chat_id'], |
||
| 361 | 'createChatInviteLink' => ['chat_id'], |
||
| 362 | 'editChatInviteLink' => ['chat_id'], |
||
| 363 | 'revokeChatInviteLink' => ['chat_id'], |
||
| 364 | 'approveChatJoinRequest' => ['chat_id','user_id'], |
||
| 365 | 'declineChatJoinRequest' => ['chat_id','user_id'], |
||
| 366 | 'setChatPhoto' => ['chat_id'], |
||
| 367 | 'deleteChatPhoto' => ['chat_id'], |
||
| 368 | 'setChatTitle' => ['chat_id'], |
||
| 369 | 'setChatDescription' => ['chat_id'], |
||
| 370 | 'pinChatMessage' => ['chat_id'], |
||
| 371 | 'unpinChatMessage' => ['chat_id'], |
||
| 372 | 'unpinAllChatMessages' => ['chat_id'], |
||
| 373 | 'leaveChat' => ['chat_id'], |
||
| 374 | 'getChat' => ['chat_id'], |
||
| 375 | 'getChatAdministrators' => ['chat_id'], |
||
| 376 | 'getChatMembersCount' => ['chat_id'], |
||
| 377 | 'getChatMember' => ['chat_id','user_id'], |
||
| 378 | 'setChatStickerSet' => ['chat_id'], |
||
| 379 | 'deleteChatStickerSet' => ['chat_id'], |
||
| 380 | 'answerCallbackQuery' => ['callback_query_id'], |
||
| 381 | 'setMyCommands' => [], |
||
| 382 | 'deleteMyCommands' => [], |
||
| 383 | 'getMyCommands' => [], |
||
| 384 | 'setChatMenuButton' => [], |
||
| 385 | 'getChatMenuButton' => [], |
||
| 386 | 'setMyDefaultAdministratorRights' => [], |
||
| 387 | 'getMyDefaultAdministratorRights' => [], |
||
| 388 | 'editMessageText' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
||
| 389 | 'editMessageCaption' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
||
| 390 | 'editMessageMedia' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
||
| 391 | 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
||
| 392 | 'stopPoll' => ['chat_id','message_id'], |
||
| 393 | 'deleteMessage' => ['chat_id','message_id'], |
||
| 394 | 'sendSticker' => ['chat_id'], |
||
| 395 | 'getStickerSet' => [], |
||
| 396 | 'uploadStickerFile' => ['user_id'], |
||
| 397 | 'createNewStickerSet' => ['user_id'], |
||
| 398 | 'addStickerToSet' => ['user_id'], |
||
| 399 | 'setStickerPositionInSet' => [], |
||
| 400 | 'deleteStickerFromSet' => [], |
||
| 401 | 'setStickerSetThumb' => ['user_id'], |
||
| 402 | 'answerInlineQuery' => ['inline_query_id'], |
||
| 403 | 'sendInvoice' => ['chat_id'], |
||
| 404 | 'answerWebAppQuery' => [], |
||
| 405 | 'answerShippingQuery' => ['shipping_query_id'], |
||
| 406 | 'answerPreCheckoutQuery' => ['pre_checkout_query_id'], |
||
| 407 | 'setPassportDataErrors' => ['user_id'], |
||
| 408 | 'sendGame' => ['chat_id'], |
||
| 409 | 'setGameScore' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
||
| 410 | 'getGameHighScores' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']] |
||
| 411 | ]; |
||
| 412 | |||
| 413 | |||
| 414 | public static function __callStatic (string $name, array $arguments) {
|
||
| 415 | if ($action = self::methodAction($name)) {
|
||
| 416 | self::keysName($action,$arguments); |
||
| 417 | self::readyFile($action,$arguments); |
||
| 418 | self::setDefaults($action,$arguments); |
||
|
|
|||
| 419 | if (isset($arguments['answer'])) {
|
||
| 420 | return answer::init($action,$arguments); |
||
| 421 | } |
||
| 422 | else {
|
||
| 423 | return curl::init($action,$arguments); |
||
| 424 | } |
||
| 425 | } |
||
| 426 | else {
|
||
| 427 | logger::write("$name method is not supported",loggerTypes::ERROR);
|
||
| 428 | } |
||
| 429 | } |
||
| 430 | |||
| 431 | private static function keysName (string $name, array &$arguments) {
|
||
| 432 | foreach ($arguments as $key => $argument) {
|
||
| 433 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) {
|
||
| 434 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
||
| 435 | unset($arguments[$key]); |
||
| 436 | } |
||
| 437 | } |
||
| 438 | } |
||
| 439 | |||
| 440 | private static function methodAction(string $name): string|false {
|
||
| 442 | } |
||
| 443 | |||
| 444 | private static function readyFile(string $name, array &$arguments) {
|
||
| 456 | } |
||
| 457 | } |
||
| 458 | } |
||
| 459 | } |
||
| 460 | |||
| 461 | private static function methodFile(string $name): array|false {
|
||
| 463 | } |
||
| 464 | |||
| 465 | private static function setDefaults(string $name, array &$arguments) {
|
||
| 480 | } |
||
| 481 | } |
||
| 482 | } |
||
| 483 | |||
| 484 | public static function catchFields (string $field): int|string|bool {
|
||
| 625 | } |