function LineLengthSniff::getLineLength
Returns the length of a defined line.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
int $currentLine The current line.:
Return value
int
File
-
vendor/
drupal/ coder/ coder_sniffer/ Drupal/ Sniffs/ Files/ LineLengthSniff.php, line 119
Class
- LineLengthSniff
- Checks comment lines in the file, and throws warnings if they are over 80 characters in length.
Namespace
Drupal\Sniffs\FilesCode
public function getLineLength(File $phpcsFile, $currentLine) {
$tokens = $phpcsFile->getTokens();
$tokenCount = 0;
$currentLineContent = '';
$trim = strlen($phpcsFile->eolChar) * -1;
for (; $tokenCount < $phpcsFile->numTokens; $tokenCount++) {
if ($tokens[$tokenCount]['line'] === $currentLine) {
$currentLineContent .= $tokens[$tokenCount]['content'];
}
}
return strlen($currentLineContent);
}