| Conditions | 13 |
| Paths | 2080 |
| Total Lines | 42 |
| Code Lines | 26 |
| Lines | 8 |
| Ratio | 19.05 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 33 | 8 | 'message' => Message::class, |
|
| 34 | 'edited_message' => EditedMessage::class, |
||
| 35 | 'inline_query' => InlineQuery::class, |
||
| 36 | 'chosen_inline_result' => ChosenInlineResult::class, |
||
| 37 | 'callback_query' => CallbackQuery::class, |
||
| 38 | ]; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Get the update type based on the set properties |
||
| 43 | * |
||
| 44 | * @return string|null |
||
| 45 | */ |
||
| 46 | public function getUpdateType() |
||
| 47 | { |
||
| 48 | $types = [ |
||
| 49 | 'message', |
||
| 50 | 'edited_message', |
||
| 51 | 'inline_query', |
||
| 52 | 'chosen_inline_result', |
||
| 53 | 'callback_query', |
||
| 54 | ]; |
||
| 55 | foreach ($types as $type) { |
||
| 56 | if ($this->getProperty($type)) { |
||
| 57 | return $type; |
||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | return null; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Get update content |
||
| 66 | * |
||
| 67 | * @return \Longman\TelegramBot\Entities\CallbackQuery |
||
| 68 | * |\Longman\TelegramBot\Entities\ChosenInlineResult |
||
| 69 | * |\Longman\TelegramBot\Entities\InlineQuery |
||
| 70 | * |\Longman\TelegramBot\Entities\Message |
||
| 71 | */ |
||
| 72 | public function getUpdateContent() |
||
| 73 | { |
||
| 74 | if ($update_type = $this->getUpdateType()) { |
||
| 75 | return $this->getProperty($update_type); |
||
| 81 |