| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
| 19 | { |
||
| 20 | $tokens = $phpcsFile->getTokens(); |
||
| 21 | $token = $tokens[$stackPtr]; |
||
| 22 | |||
| 23 | // Skip function without body. |
||
| 24 | if (isset($token['scope_opener']) === false) { |
||
| 25 | return 0; |
||
| 26 | } |
||
| 27 | |||
| 28 | $firstToken = $tokens[$token['scope_opener']]; |
||
| 29 | $lastToken = $tokens[$token['scope_closer']]; |
||
| 30 | $length = $lastToken['line'] - $firstToken['line']; |
||
| 31 | |||
| 32 | if ($length > $this->maxLength) { |
||
| 33 | $tokenType = strtolower(substr($token['type'], 2)); |
||
| 34 | $error = "Function is {$length} lines. Must be {$this->maxLength} lines or fewer."; |
||
| 35 | $phpcsFile->addError($error, $stackPtr, sprintf('%sTooBig', ucfirst($tokenType))); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | } |
||
| 39 |