| Conditions | 21 |
| Paths | 21 |
| Total Lines | 52 |
| Code Lines | 32 |
| 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 |
||
| 91 | private static function processHandler(): void { |
||
| 92 | if (settings::$handler) { |
||
| 93 | if (isset(BPT::$update->message)) { |
||
| 94 | if (self::handlerExist('message')) { |
||
| 95 | BPT::$handler->message(BPT::$update->message); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | elseif (isset(BPT::$update->edited_message)) { |
||
| 99 | if (self::handlerExist('edited_message')) { |
||
| 100 | BPT::$handler->edited_message(BPT::$update->edited_message); |
||
| 101 | } |
||
| 102 | } |
||
| 103 | elseif (isset(BPT::$update->channel_post)) { |
||
| 104 | if (self::handlerExist('channel_post')) { |
||
| 105 | BPT::$handler->channel_post(BPT::$update->channel_post); |
||
| 106 | } |
||
| 107 | } |
||
| 108 | elseif (isset(BPT::$update->edited_channel_post)) { |
||
| 109 | if (self::handlerExist('edited_channel_post')) { |
||
| 110 | BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post); |
||
| 111 | } |
||
| 112 | } |
||
| 113 | elseif (isset(BPT::$update->inline_query)) { |
||
| 114 | if (self::handlerExist('inline_query')) { |
||
| 115 | BPT::$handler->inline_query(BPT::$update->inline_query); |
||
| 116 | } |
||
| 117 | } |
||
| 118 | elseif (isset(BPT::$update->callback_query)) { |
||
| 119 | if (self::handlerExist('callback_query')) { |
||
| 120 | BPT::$handler->callback_query(BPT::$update->callback_query); |
||
| 121 | } |
||
| 122 | } |
||
| 123 | elseif (isset(BPT::$update->my_chat_member)) { |
||
| 124 | if (self::handlerExist('my_chat_member')) { |
||
| 125 | BPT::$handler->my_chat_member(BPT::$update->my_chat_member); |
||
| 126 | } |
||
| 127 | } |
||
| 128 | elseif (isset(BPT::$update->chat_member)) { |
||
| 129 | if (self::handlerExist('chat_member')) { |
||
| 130 | BPT::$handler->chat_member(BPT::$update->chat_member); |
||
| 131 | } |
||
| 132 | } |
||
| 133 | elseif (isset(BPT::$update->chat_join_request)) { |
||
| 134 | if (self::handlerExist('chat_join_request')) { |
||
| 135 | BPT::$handler->chat_join_request(BPT::$update->chat_join_request); |
||
| 136 | } |
||
| 137 | } |
||
| 138 | elseif (self::handlerExist('something_else')) { |
||
| 139 | BPT::$handler->something_else(BPT::$update); |
||
| 140 | } |
||
| 141 | else { |
||
| 142 | logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
||
| 143 | } |
||
| 153 | } |