| Conditions | 13 | 
| Paths | 70 | 
| Total Lines | 45 | 
| 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  | 
            ||
| 68 | public function insertSemicolon(array $parameters = [])  | 
            ||
| 69 |     { | 
            ||
| 70 |         if (strpos($parameters['filePath'], 'ignition/tests/Solutions') !== false) { | 
            ||
| 71 | $file = $parameters['filePath'];  | 
            ||
| 72 |         } else { | 
            ||
| 73 | $file = app_path().$parameters['filePath'];  | 
            ||
| 74 | }  | 
            ||
| 75 | |||
| 76 |         if (! is_file($file)) { | 
            ||
| 77 | return false;  | 
            ||
| 78 | }  | 
            ||
| 79 | $contents = file_get_contents($file);  | 
            ||
| 80 | $tokens = token_get_all($contents);  | 
            ||
| 81 | |||
| 82 | $reverseTokens = array_reverse($tokens);  | 
            ||
| 83 | |||
| 84 | $output = [];  | 
            ||
| 85 | $insertSemicolon = false;  | 
            ||
| 86 | $line = 0;  | 
            ||
| 87 |         foreach ($reverseTokens as $token) { | 
            ||
| 88 | $char = isset($token[1]) ? $token[1] : $token;  | 
            ||
| 89 | |||
| 90 | $output[] = $char;  | 
            ||
| 91 | |||
| 92 |             if (isset($token[2])) { | 
            ||
| 93 | $line = $token[2];  | 
            ||
| 94 | }  | 
            ||
| 95 |             if (is_string($token) && $line == $parameters['lineNumber'] && $char == $parameters['unexpected']) { | 
            ||
| 96 | $insertSemicolon = true;  | 
            ||
| 97 | }  | 
            ||
| 98 |             if ($insertSemicolon && isset($token[0]) && $token[0] == T_WHITESPACE) { | 
            ||
| 99 | $insertSemicolon = false;  | 
            ||
| 100 | $output[] = ';';  | 
            ||
| 101 | }  | 
            ||
| 102 | }  | 
            ||
| 103 |         $proposedFix = implode('', array_reverse($output)); | 
            ||
| 104 | |||
| 105 |         $result = exec(sprintf('echo %s | php -l', escapeshellarg($proposedFix)), $output, $exit); | 
            ||
| 106 | |||
| 107 |         if (Str::contains($result, 'No syntax errors')) { | 
            ||
| 108 | return $proposedFix;  | 
            ||
| 109 | }  | 
            ||
| 110 | |||
| 111 | return false;  | 
            ||
| 112 | }  | 
            ||
| 113 | }  | 
            ||
| 114 |