Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LineLengthSniff.php

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\Files

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal