| Conditions | 14 | 
| Paths | 78 | 
| Total Lines | 69 | 
| 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  | 
            ||
| 106 | public function processClose(File $phpcsFile, $stackPtr)  | 
            ||
| 107 |     { | 
            ||
| 108 | $tokens = $phpcsFile->getTokens();  | 
            ||
| 109 | |||
| 110 | // Just in case.  | 
            ||
| 111 |         if (isset($tokens[$stackPtr]['scope_closer']) === false) { | 
            ||
| 112 | return;  | 
            ||
| 113 | }  | 
            ||
| 114 | |||
| 115 | $closeBrace = $tokens[$stackPtr]['scope_closer'];  | 
            ||
| 116 |         if ($tokens[($closeBrace - 1)]['code'] === T_WHITESPACE) { | 
            ||
| 117 | $prevContent = $tokens[($closeBrace - 1)]['content'];  | 
            ||
| 118 |             if ($prevContent !== $phpcsFile->eolChar) { | 
            ||
| 119 | $blankSpace = substr($prevContent, strpos($prevContent, $phpcsFile->eolChar));  | 
            ||
| 120 | $spaces = strlen($blankSpace);  | 
            ||
| 121 |                 if ($spaces !== 0) { | 
            ||
| 122 |                     if ($tokens[($closeBrace - 1)]['line'] !== $tokens[$closeBrace]['line']) { | 
            ||
| 123 | $error = 'Expected 0 spaces before closing brace; newline found';  | 
            ||
| 124 | $fix = $phpcsFile->addFixableError($error, $closeBrace, 'NewLineBeforeCloseBrace');  | 
            ||
| 125 |                     } else { | 
            ||
| 126 | $error = 'Expected 0 spaces before closing brace; %s found';  | 
            ||
| 127 | $data = array($spaces);  | 
            ||
| 128 | $fix = $phpcsFile->addFixableError($error, $closeBrace, 'SpaceBeforeCloseBrace', $data);  | 
            ||
| 129 | }//end if  | 
            ||
| 130 | |||
| 131 |                     if ($fix === true) { | 
            ||
| 132 | $phpcsFile->fixer->beginChangeset();  | 
            ||
| 133 | $phpcsFile->fixer->replaceToken(($closeBrace - 1), '');  | 
            ||
| 134 | $phpcsFile->fixer->endChangeset();  | 
            ||
| 135 | }  | 
            ||
| 136 | }//end if  | 
            ||
| 137 | }//end if  | 
            ||
| 138 | }//end if  | 
            ||
| 139 | |||
| 140 | // Check that the closing brace has one blank line after it.  | 
            ||
| 141 | $nextContent = $phpcsFile->findNext(array(T_WHITESPACE), ($closeBrace + 1), null, true);  | 
            ||
| 142 |         if ($nextContent !== false) { | 
            ||
| 143 | $difference = ($tokens[$nextContent]['line'] - $tokens[$closeBrace]['line'] - 1);  | 
            ||
| 144 |             if ($difference < 0) { | 
            ||
| 145 | $difference = 0;  | 
            ||
| 146 | }  | 
            ||
| 147 | |||
| 148 |             if ($difference !== 1) { | 
            ||
| 149 | $error = 'Closing brace of a %s must be followed by a single blank line; found %s';  | 
            ||
| 150 | $data = array(  | 
            ||
| 151 | $tokens[$stackPtr]['content'],  | 
            ||
| 152 | $difference,  | 
            ||
| 153 | );  | 
            ||
| 154 | $fix = $phpcsFile->addFixableError($error, $closeBrace, 'NewlinesAfterCloseBrace', $data);  | 
            ||
| 155 |                 if ($fix === true) { | 
            ||
| 156 | $phpcsFile->fixer->beginChangeset();  | 
            ||
| 157 | |||
| 158 |                     if ($difference > 1) { | 
            ||
| 159 |                         for ($i = ($closeBrace + 1); $i < $nextContent; $i++) { | 
            ||
| 160 |                             if ($tokens[$i]['line'] === $tokens[$nextContent]['line']) { | 
            ||
| 161 | // Keep existing indentation.  | 
            ||
| 162 | break;  | 
            ||
| 163 | }  | 
            ||
| 164 | |||
| 165 | $phpcsFile->fixer->replaceToken($i, '');  | 
            ||
| 166 | }  | 
            ||
| 167 | }  | 
            ||
| 168 | |||
| 169 | $phpcsFile->fixer->addNewline($closeBrace);  | 
            ||
| 170 | $phpcsFile->fixer->endChangeset();  | 
            ||
| 171 | }  | 
            ||
| 172 | }//end if  | 
            ||
| 173 | }//end if  | 
            ||
| 174 | }//end processClose()  | 
            ||
| 175 | }//end class  | 
            ||
| 176 |