Comments_Token_Parser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A decide_comments_end() 0 2 1
A getTag() 0 3 1
A parse() 0 11 1
1
<?php
2
namespace Rarst\Meadow;
3
4
use Twig_Token;
5
6
class Comments_Token_Parser extends \Twig_TokenParser {
7
8
	/**
9
	 * Parses a token and returns a node.
10
	 *
11
	 * @param Twig_Token $token
12
	 *
13
	 * @return Comments_Node
14
	 */
15
	public function parse( Twig_Token $token ) {
16
17
		$nodes  = array();
18
		$parser = $this->parser;
19
		$stream = $parser->getStream();
20
21
		$stream->expect( Twig_Token::BLOCK_END_TYPE );
22
		$nodes['callback'] = $parser->subparse( array( $this, 'decide_comments_end' ), true );
23
		$stream->expect( Twig_Token::BLOCK_END_TYPE );
24
25
		return new Comments_Node( $nodes, array(), $token->getLine(), $this->getTag() );
26
	}
27
28
	/**
29
	 * @return string
30
	 */
31
	public function getTag() {
32
33
		return 'comments';
34
	}
35
36
	/**
37
	 * @param Twig_Token $token
38
	 *
39
	 * @return bool
40
	 */
41
	public function decide_comments_end( Twig_Token $token ) {
42
		return $token->test( 'endcomments' );
43
	}
44
}