| Conditions | 10 | 
| Paths | 17 | 
| Total Lines | 25 | 
| 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 | ||
| 92 | protected function generateProposedFileFromTokens(array $tokens, int $lineNumber, string $unexpectedChar) | ||
| 93 |     { | ||
| 94 | $reverseTokens = array_reverse($tokens); | ||
| 95 | $output = []; | ||
| 96 | $insertSemicolon = false; | ||
| 97 | $line = 0; | ||
| 98 |         foreach ($reverseTokens as $token) { | ||
| 99 | $char = isset($token[1]) ? $token[1] : $token; | ||
| 100 | |||
| 101 | $output[] = $char; | ||
| 102 | |||
| 103 |             if (isset($token[2])) { | ||
| 104 | $line = $token[2]; | ||
| 105 | } | ||
| 106 |             if (is_string($token) && $line == $lineNumber && $char == $unexpectedChar) { | ||
| 107 | $insertSemicolon = true; | ||
| 108 | } | ||
| 109 |             if ($insertSemicolon && isset($token[0]) && $token[0] == T_WHITESPACE) { | ||
| 110 | $insertSemicolon = false; | ||
| 111 | $output[] = ';'; | ||
| 112 | } | ||
| 113 | } | ||
| 114 | |||
| 115 |         return implode('', array_reverse($output)); | ||
| 116 | } | ||
| 117 | } | ||
| 118 |