protected function Twig_Tests_LexerTest::countToken in Zircon Profile 8
Same name and namespace in other branches
- 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
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;
}