You are here

public function Drupal_Sniffs_CSS_ColourDefinitionSniff::process in Coder 7.2

Processes the tokens that this sniff is interested in.

Parameters

PHP_CodeSniffer_File $phpcsFile The file where the token was found.:

int $stackPtr The position in the stack where: the token was found.

Return value

void

File

coder_sniffer/Drupal/Sniffs/CSS/ColourDefinitionSniff.php, line 53

Class

Drupal_Sniffs_CSS_ColourDefinitionSniff
Squiz_Sniffs_CSS_ColourDefinitionSniff.

Code

public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
  $tokens = $phpcsFile
    ->getTokens();
  $colour = $tokens[$stackPtr]['content'];
  $expected = strtolower($colour);
  if ($colour !== $expected) {
    $error = 'CSS colours must be defined in lowercase; expected %s but found %s';
    $data = array(
      $expected,
      $colour,
    );
    $phpcsFile
      ->addError($error, $stackPtr, 'NotLower', $data);
  }
}