ModelTokenParser::getTag()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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