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 |
||
95 | private static function processHandler(): void { |
||
96 | if (!settings::$handler) { |
||
97 | return; |
||
98 | } |
||
99 | if (isset(BPT::$update->message)) { |
||
100 | if (self::handlerExist('message')) { |
||
101 | BPT::$handler->message(BPT::$update->message); |
||
102 | } |
||
103 | } |
||
104 | elseif (isset(BPT::$update->edited_message)) { |
||
105 | if (self::handlerExist('edited_message')) { |
||
106 | BPT::$handler->edited_message(BPT::$update->edited_message); |
||
107 | } |
||
108 | } |
||
109 | elseif (isset(BPT::$update->channel_post)) { |
||
110 | if (self::handlerExist('channel_post')) { |
||
111 | BPT::$handler->channel_post(BPT::$update->channel_post); |
||
112 | } |
||
113 | } |
||
114 | elseif (isset(BPT::$update->edited_channel_post)) { |
||
115 | if (self::handlerExist('edited_channel_post')) { |
||
116 | BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post); |
||
117 | } |
||
118 | } |
||
119 | elseif (isset(BPT::$update->inline_query)) { |
||
120 | if (self::handlerExist('inline_query')) { |
||
121 | BPT::$handler->inline_query(BPT::$update->inline_query); |
||
122 | } |
||
123 | } |
||
124 | elseif (isset(BPT::$update->callback_query)) { |
||
125 | if (self::handlerExist('callback_query')) { |
||
126 | BPT::$handler->callback_query(BPT::$update->callback_query); |
||
127 | } |
||
128 | } |
||
129 | elseif (isset(BPT::$update->my_chat_member)) { |
||
130 | if (self::handlerExist('my_chat_member')) { |
||
131 | BPT::$handler->my_chat_member(BPT::$update->my_chat_member); |
||
132 | } |
||
133 | } |
||
134 | elseif (isset(BPT::$update->chat_member)) { |
||
135 | if (self::handlerExist('chat_member')) { |
||
136 | BPT::$handler->chat_member(BPT::$update->chat_member); |
||
137 | } |
||
138 | } |
||
139 | elseif (isset(BPT::$update->chat_join_request)) { |
||
140 | if (self::handlerExist('chat_join_request')) { |
||
141 | BPT::$handler->chat_join_request(BPT::$update->chat_join_request); |
||
142 | } |
||
143 | } |
||
144 | elseif (self::handlerExist('something_else')) { |
||
145 | BPT::$handler->something_else(BPT::$update); |
||
146 | } |
||
147 | else { |
||
148 | logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
||
149 | } |
||
158 | } |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.