| Conditions | 11 | 
| Paths | 40 | 
| Total Lines | 79 | 
| Code Lines | 38 | 
| 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  | 
            ||
| 49 | public function process(\PHP_CodeSniffer_File $phpcsFile, $stackPtr)  | 
            ||
| 50 |     { | 
            ||
| 51 |         if ($this->supportsBelow('5.2')) { | 
            ||
| 52 | $phpcsFile->addError(  | 
            ||
| 53 | 'Closures / anonymous functions are not available in PHP 5.2 or earlier',  | 
            ||
| 54 | $stackPtr,  | 
            ||
| 55 | 'Found'  | 
            ||
| 56 | );  | 
            ||
| 57 | }  | 
            ||
| 58 | |||
| 59 | $isStatic = $this->isClosureStatic($phpcsFile, $stackPtr);  | 
            ||
| 60 | $usesThis = $this->findThisUsageInClosure($phpcsFile, $stackPtr);  | 
            ||
| 61 | |||
| 62 |         if ($this->supportsBelow('5.3')) { | 
            ||
| 63 | /*  | 
            ||
| 64 | * Closures can only be declared as static since PHP 5.4.  | 
            ||
| 65 | */  | 
            ||
| 66 |             if ($isStatic === true) { | 
            ||
| 67 | $phpcsFile->addError(  | 
            ||
| 68 | 'Closures / anonymous functions could not be declared as static in PHP 5.3 or earlier',  | 
            ||
| 69 | $stackPtr,  | 
            ||
| 70 | 'StaticFound'  | 
            ||
| 71 | );  | 
            ||
| 72 | }  | 
            ||
| 73 | |||
| 74 | /*  | 
            ||
| 75 | * Closures declared within classes only have access to $this since PHP 5.4.  | 
            ||
| 76 | */  | 
            ||
| 77 |             if ($usesThis !== false) { | 
            ||
| 78 | $thisFound = $usesThis;  | 
            ||
| 79 |                 do { | 
            ||
| 80 | $phpcsFile->addError(  | 
            ||
| 81 | 'Closures / anonymous functions did not have access to $this in PHP 5.3 or earlier',  | 
            ||
| 82 | $thisFound,  | 
            ||
| 83 | 'ThisFound'  | 
            ||
| 84 | );  | 
            ||
| 85 | |||
| 86 | $thisFound = $this->findThisUsageInClosure($phpcsFile, $stackPtr, ($thisFound + 1));  | 
            ||
| 87 | |||
| 88 | } while ($thisFound !== false);  | 
            ||
| 89 | }  | 
            ||
| 90 | }  | 
            ||
| 91 | |||
| 92 | /*  | 
            ||
| 93 | * Check for correct usage.  | 
            ||
| 94 | */  | 
            ||
| 95 |         if ($this->supportsAbove('5.4') && $usesThis !== false) { | 
            ||
| 96 | |||
| 97 | $thisFound = $usesThis;  | 
            ||
| 98 | |||
| 99 |             do { | 
            ||
| 100 | /*  | 
            ||
| 101 | * Closures only have access to $this if not declared as static.  | 
            ||
| 102 | */  | 
            ||
| 103 |                 if ($isStatic === true) { | 
            ||
| 104 | $phpcsFile->addError(  | 
            ||
| 105 | 'Closures / anonymous functions declared as static do not have access to $this',  | 
            ||
| 106 | $thisFound,  | 
            ||
| 107 | 'ThisFoundInStatic'  | 
            ||
| 108 | );  | 
            ||
| 109 | }  | 
            ||
| 110 | |||
| 111 | /*  | 
            ||
| 112 | * Closures only have access to $this if used within a class context.  | 
            ||
| 113 | */  | 
            ||
| 114 |                 elseif ($this->inClassScope($phpcsFile, $stackPtr, false) === false) { | 
            ||
| 115 | $phpcsFile->addWarning(  | 
            ||
| 116 | 'Closures / anonymous functions only have access to $this if used within a class or when bound to an object using bindTo(). Please verify.',  | 
            ||
| 117 | $thisFound,  | 
            ||
| 118 | 'ThisFoundOutsideClass'  | 
            ||
| 119 | );  | 
            ||
| 120 | }  | 
            ||
| 121 | |||
| 122 | $thisFound = $this->findThisUsageInClosure($phpcsFile, $stackPtr, ($thisFound + 1));  | 
            ||
| 123 | |||
| 124 | } while ($thisFound !== false);  | 
            ||
| 125 | }  | 
            ||
| 126 | |||
| 127 | }//end process()  | 
            ||
| 128 | |||
| 187 |