CssTokenParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 15 2
A getTag() 0 3 1
1
<?php
2
3
namespace Braunstetter\AssetsPushBundle\Twig\TokenParser;
4
5
use Braunstetter\AssetsPushBundle\Twig\Nodes\CssNode;
6
use Twig\Node\Node;
7
use Twig\Token;
8
use Twig\TokenParser\AbstractTokenParser;
9
10
class CssTokenParser extends AbstractTokenParser
11
{
12
13
    /**
14
     * @inheritDoc
15
     */
16
    public function parse(Token $token): Node|CssNode
17
    {
18
        $parser = $this->parser;
19
        $stream = $parser->getStream();
20
21
        $data = null;
22
23
        // keep collecting strings until the block ends
24
        while (!$stream->test(Token::BLOCK_END_TYPE)) {
25
            $data = $stream->expect(Token::STRING_TYPE)->getValue();
26
        }
27
28
        $stream->expect(Token::BLOCK_END_TYPE);
29
30
        return new CssNode($data, $token->getLine(), $this->getTag());
31
    }
32
33
    /**
34
     * @inheritDoc
35
     */
36
    public function getTag(): string
37
    {
38
        return 'css';
39
    }
40
}