| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types = 1); |
||
| 35 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
| 36 | { |
||
| 37 | $tokens = $phpcsFile->getTokens(); |
||
| 38 | $token = $tokens[$stackPtr]; |
||
| 39 | |||
| 40 | // Skip function without body. |
||
| 41 | if (isset($token['scope_opener']) === false) { |
||
| 42 | return; |
||
| 43 | } |
||
| 44 | |||
| 45 | $firstToken = $tokens[$token['scope_opener']]; |
||
| 46 | $lastToken = $tokens[$token['scope_closer']]; |
||
| 47 | $length = $lastToken['line'] - $firstToken['line']; |
||
| 48 | |||
| 49 | if ($length > $this->maxLength) { |
||
| 50 | $tokenType = strtolower(substr($token['type'], 2)); |
||
| 51 | $error = "Function is {$length} lines. Must be {$this->maxLength} lines or fewer."; |
||
| 52 | $phpcsFile->addError($error, $stackPtr, sprintf('%sTooBig', ucfirst($tokenType))); |
||
| 53 | } |
||
| 56 |