| Conditions | 10 |
| Paths | 14 |
| Total Lines | 66 |
| Code Lines | 58 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 65 | public static function set($input) |
||
| 66 | { |
||
| 67 | if (isset($input->message) || isset($input->edited_message)) { |
||
| 68 | if (isset($input->message)) $type = 'message'; |
||
| 69 | else $type = 'edited_message'; |
||
| 70 | // |
||
| 71 | self::$message_id = $input->$type->message_id; |
||
| 72 | // |
||
| 73 | self::$from_id = $input->$type->from->id; |
||
| 74 | self::$from_is_bot = $input->$type->from->is_bot; |
||
| 75 | self::$from_first_name = $input->$type->from->first_name ?? null; |
||
| 76 | self::$from_last_name = $input->$type->from->last_name ?? null; |
||
| 77 | self::$from_username = $input->$type->from->username ?? null; |
||
| 78 | self::$language_code = $input->$type->from->language_code ?? null; |
||
| 79 | // |
||
| 80 | self::$chat_id = $input->$type->chat->id; |
||
| 81 | self::$chat_type = $input->$type->chat->type ?? null; |
||
| 82 | self::$chat_title = $input->$type->chat->title; |
||
| 83 | self::$chat_username = $input->$type->chat->username ?? null; |
||
| 84 | // |
||
| 85 | self::$text = $input->$type->text ?? null; |
||
| 86 | self::$caption = $input->$type->caption ?? null; |
||
| 87 | self::$entities = $input->$type->entities ?? $input->$type->caption_entities ?? null; |
||
| 88 | // |
||
| 89 | self::$left_chat_member_id = $input->$type->left_chat_member->id ?? null; |
||
| 90 | if (isset($input->$type->reply_to_message)) { |
||
| 91 | self::$reply_to_from_id = $input->$type->reply_to_message->from->id; |
||
| 92 | self::$reply_to_from_is_bot = $input->$type->reply_to_message->from->is_bot; |
||
| 93 | self::$reply_to_from_first_name = $input->$type->reply_to_message->from->first_name ?? null; |
||
| 94 | self::$reply_to_from_last_name = $input->$type->reply_to_message->from->last_name ?? null; |
||
| 95 | self::$reply_to_from_username = $input->$type->reply_to_message->from->username ?? null; |
||
| 96 | self::$reply_to_from_language_code = $input->$type->reply_to_message->from->language_code ?? null; |
||
| 97 | self::$reply_to_text = $input->$type->reply_to_message->text ?? null; |
||
| 98 | self::$reply_to_caption = $input->$type->reply_to_message->caption ?? null; |
||
| 99 | } elseif(isset($input->message->new_chat_member)){ |
||
| 100 | self::$new_chat_member_id = $input->message->new_chat_member->id; |
||
| 101 | self::$new_chat_member_is_bot = $input->message->new_chat_member->is_bot; |
||
| 102 | self::$new_chat_member_first_name = $input->message->new_chat_member->first_name ?? null; |
||
| 103 | self::$new_chat_member_last_name = $input->message->new_chat_member->last_name ?? null; |
||
| 104 | self::$new_chat_member_username = $input->message->new_chat_member->username ?? null; |
||
| 105 | self::$new_chat_member_language_code = $input->message->new_chat_member->language_code ?? null; |
||
| 106 | } elseif(isset($input->message->forward_from_chat)){ |
||
| 107 | self::$forward_from_chat_id = $input->message->forward_from_chat->id; |
||
| 108 | self::$forward_from_chat_type = $input->message->forward_from_chat->type; |
||
| 109 | self::$forward_from_chat_title = $input->message->forward_from_chat->title; |
||
| 110 | self::$forward_from_chat_username = $input->message->forward_from_chat->username ?? null; |
||
| 111 | } elseif(isset($input->message->new_chat_photo)){ |
||
| 112 | self::$new_chat_photo_file_id = $input->message->new_chat_photo->file_id; |
||
| 113 | } elseif(isset($input->message->new_chat_title)){ |
||
| 114 | self::$new_chat_title = $input->message->new_chat_title; |
||
| 115 | } |
||
| 116 | } elseif (isset($input->callback_query)) { |
||
| 117 | self::$message_id = $input->callback_query->message->message_id; |
||
| 118 | self::$from_id = $input->callback_query->from->id; |
||
| 119 | self::$from_is_bot = $input->callback_query->from->is_bot; |
||
| 120 | self::$from_first_name = $input->callback_query->from->first_name ?? null; |
||
| 121 | self::$from_last_name = $input->callback_query->from->last_name ?? null; |
||
| 122 | self::$from_username = $input->callback_query->from->username ?? null; |
||
| 123 | self::$language_code = $input->callback_query->from->language_code ?? null; |
||
| 124 | self::$chat_id = $input->callback_query->message->chat->id; |
||
| 125 | self::$chat_type = $input->callback_query->message->chat->type ?? null; |
||
| 126 | self::$chat_title = $input->callback_query->message->chat->title; |
||
| 127 | self::$chat_username = $input->callback_query->message->chat->username ?? null; |
||
| 128 | self::$text = $input->callback_query->message->text ?? null; |
||
| 129 | self::$date = $input->callback_query->message->date ?? null; |
||
| 130 | self::$callback_query_data = $input->callback_query->data ?? null; |
||
| 131 | } |
||
| 165 |