You are here

protected function Twig_Tests_LexerTest::countToken in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/test/Twig/Tests/LexerTest.php \Twig_Tests_LexerTest::countToken()
1 call to Twig_Tests_LexerTest::countToken()
Twig_Tests_LexerTest::testBracketsNesting in vendor/twig/twig/test/Twig/Tests/LexerTest.php

File

vendor/twig/twig/test/Twig/Tests/LexerTest.php, line 43

Class

Twig_Tests_LexerTest

Code

protected function countToken($template, $type, $value = null) {
  $lexer = new Twig_Lexer(new Twig_Environment($this
    ->getMock('Twig_LoaderInterface')));
  $stream = $lexer
    ->tokenize($template);
  $count = 0;
  while (!$stream
    ->isEOF()) {
    $token = $stream
      ->next();
    if ($type === $token
      ->getType()) {
      if (null === $value || $value === $token
        ->getValue()) {
        ++$count;
      }
    }
  }
  return $count;
}