MinifyHtmlTokenParser::decideHtmlCompressEnd()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace voku\twig;
6
7
use Twig\Token;
8
use Twig\TokenParser\AbstractTokenParser;
9
10
class MinifyHtmlTokenParser extends AbstractTokenParser
11
{
12
    /**
13
     * @param Token $token
14
     *
15
     * @return bool
16
     */
17 2
    public function decideHtmlCompressEnd(Token $token): bool
18
    {
19 2
        return $token->test('endhtmlcompress');
20
    }
21
22
    /** @noinspection PhpMissingParentCallCommonInspection */
23 6
    public function getTag(): string
24
    {
25 6
        return 'htmlcompress';
26
    }
27
28
    /**
29
     * @param Token $token
30
     *
31
     * @return MinifyHtmlNode
32
     */
33 2
    public function parse(Token $token): MinifyHtmlNode
34
    {
35 2
        $lineNumber = $token->getLine();
36 2
        $stream = $this->parser->getStream();
37 2
        $stream->expect(Token::BLOCK_END_TYPE);
38 2
        $body = $this->parser->subparse([$this, 'decideHtmlCompressEnd'], true);
39 2
        $stream->expect(Token::BLOCK_END_TYPE);
40 2
        $nodes = ['body' => $body];
41
42 2
        return new MinifyHtmlNode($nodes, [], $lineNumber, $this->getTag());
43
    }
44
}
45