ShopUiCompatibilityDefineTwigTokenParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
c 1
b 0
f 0
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 12 1
A getTag() 0 3 1
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Yves\ShopUiCompatibility\Twig\TokenParser;
9
10
use SprykerEco\Yves\ShopUiCompatibility\Twig\Node\ShopUiCompatibilityDefineTwigNode;
11
use Twig_Token;
0 ignored issues
show
Bug introduced by
The type Twig_Token was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Twig_TokenParser;
0 ignored issues
show
Bug introduced by
The type Twig_TokenParser was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
class ShopUiCompatibilityDefineTwigTokenParser extends Twig_TokenParser
15
{
16
    /**
17
     * @return string
18
     */
19
    public function getTag(): string
20
    {
21
        return 'define';
22
    }
23
24
    /**
25
     * @param \Twig_Token $token
26
     *
27
     * @return \SprykerEco\Yves\ShopUiCompatibility\Twig\Node\ShopUiCompatibilityDefineTwigNode
28
     */
29
    public function parse(Twig_Token $token): ShopUiCompatibilityDefineTwigNode
30
    {
31
        $parser = $this->parser;
32
        $stream = $parser->getStream();
33
        $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
34
        $stream->expect(Twig_Token::OPERATOR_TYPE, '=');
35
        $value = $parser->getExpressionParser()->parseExpression();
36
        $line = $token->getLine();
37
        $tag = $this->getTag();
38
        $stream->expect(Twig_Token::BLOCK_END_TYPE);
39
40
        return new ShopUiCompatibilityDefineTwigNode($name, $value, $line, $tag);
41
    }
42
}
43