Conditions | 11 |
Paths | 37 |
Total Lines | 19 |
Code Lines | 14 |
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 |
||
97 | private static function setMessageExtra(update &$update) { |
||
98 | if((isset($update->message) && isset($update->message->text)) || (isset($update->edited_message) && isset($update->edited_message->text))){ |
||
99 | if (isset($update->message)) $type = 'message'; |
||
100 | else $type = 'edited_message'; |
||
101 | |||
102 | $text = &$update->$type->text; |
||
103 | if (settings::$security){ |
||
104 | $text = tools::clearText($text); |
||
105 | } |
||
106 | if (str_starts_with($text, '/')){ |
||
107 | preg_match('/\/([a-zA-Z_0-9]{1,64})(@[a-zA-Z]\w{1,28}bot)?( [\S]{1,64})?/',$text,$result); |
||
108 | if (!empty($result[1])){ |
||
109 | $update->$type->commend = $result[1]; |
||
110 | } |
||
111 | if (!empty($result[2])){ |
||
112 | $update->$type->commend_username = $result[2]; |
||
113 | } |
||
114 | if (!empty($result[3])){ |
||
115 | $update->$type->commend_payload = $result[3]; |
||
116 | } |
||
120 | } |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.