| Conditions | 21 |
| Paths | 21 |
| Total Lines | 54 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 92 | private static function processHandler(): void { |
||
| 93 | if (!settings::$handler) { |
||
| 94 | return; |
||
| 95 | } |
||
| 96 | if (isset(BPT::$update->message)) { |
||
| 97 | if (self::handlerExist('message')) { |
||
| 98 | BPT::$handler->message(BPT::$update->message); |
||
| 99 | } |
||
| 100 | } |
||
| 101 | elseif (isset(BPT::$update->edited_message)) { |
||
| 102 | if (self::handlerExist('edited_message')) { |
||
| 103 | BPT::$handler->edited_message(BPT::$update->edited_message); |
||
| 104 | } |
||
| 105 | } |
||
| 106 | elseif (isset(BPT::$update->channel_post)) { |
||
| 107 | if (self::handlerExist('channel_post')) { |
||
| 108 | BPT::$handler->channel_post(BPT::$update->channel_post); |
||
| 109 | } |
||
| 110 | } |
||
| 111 | elseif (isset(BPT::$update->edited_channel_post)) { |
||
| 112 | if (self::handlerExist('edited_channel_post')) { |
||
| 113 | BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | elseif (isset(BPT::$update->inline_query)) { |
||
| 117 | if (self::handlerExist('inline_query')) { |
||
| 118 | BPT::$handler->inline_query(BPT::$update->inline_query); |
||
| 119 | } |
||
| 120 | } |
||
| 121 | elseif (isset(BPT::$update->callback_query)) { |
||
| 122 | if (self::handlerExist('callback_query')) { |
||
| 123 | BPT::$handler->callback_query(BPT::$update->callback_query); |
||
| 124 | } |
||
| 125 | } |
||
| 126 | elseif (isset(BPT::$update->my_chat_member)) { |
||
| 127 | if (self::handlerExist('my_chat_member')) { |
||
| 128 | BPT::$handler->my_chat_member(BPT::$update->my_chat_member); |
||
| 129 | } |
||
| 130 | } |
||
| 131 | elseif (isset(BPT::$update->chat_member)) { |
||
| 132 | if (self::handlerExist('chat_member')) { |
||
| 133 | BPT::$handler->chat_member(BPT::$update->chat_member); |
||
| 134 | } |
||
| 135 | } |
||
| 136 | elseif (isset(BPT::$update->chat_join_request)) { |
||
| 137 | if (self::handlerExist('chat_join_request')) { |
||
| 138 | BPT::$handler->chat_join_request(BPT::$update->chat_join_request); |
||
| 139 | } |
||
| 140 | } |
||
| 141 | elseif (self::handlerExist('something_else')) { |
||
| 142 | BPT::$handler->something_else(BPT::$update); |
||
| 143 | } |
||
| 144 | else { |
||
| 145 | logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
||
| 146 | } |
||
| 155 | } |