ModelTokenParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 26
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 9 1
A getTag() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoot\Shoot\Twig\TokenParser;
5
6
use Shoot\Shoot\Twig\Node\ModelNode;
7
use Twig\Error\SyntaxError;
8
use Twig\Node\Node;
9
use Twig\Token;
10
use Twig\TokenParser\AbstractTokenParser;
11
12
/**
13
 * Parses model tags in the token stream.
14
 *
15
 * @internal
16
 */
17
final class ModelTokenParser extends AbstractTokenParser
18
{
19
    /**
20
     * @param Token $token
21
     *
22
     * @return Node
23
     *
24
     * @throws SyntaxError
25
     */
26 7
    public function parse(Token $token): Node
27
    {
28 7
        $stream = $this->parser->getStream();
29
30 7
        $presentationModel = $stream->expect(Token::STRING_TYPE)->getValue();
31
32 7
        $stream->expect(Token::BLOCK_END_TYPE);
33
34 7
        return new ModelNode($presentationModel, $token->getLine(), $this->getTag());
35
    }
36
37
    /**
38
     * @return string
39
     */
40 7
    public function getTag(): string
41
    {
42 7
        return 'model';
43
    }
44
}
45