GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — master ( 78f8b7...0f754d )
by Elemér
04:15
created

MacroContextNodeVisitor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 41
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPriority() 0 4 1
A doEnterNode() 0 19 2
1
<?php
2
3
namespace Erelke\TwigSpreadsheetBundle\Twig\NodeVisitor;
4
5
use Erelke\TwigSpreadsheetBundle\Wrapper\PhpSpreadsheetWrapper;
6
use Twig\Environment as Twig_Environment;
7
use Twig\Node\Node as Twig_Node;
8
use Twig\NodeVisitor\AbstractNodeVisitor as Twig_BaseNodeVisitor;
9
use Twig\Node\Expression\MethodCallExpression as Twig_Node_Expression_MethodCall;
10
use Twig\Node\Expression\ConstantExpression as Twig_Node_Expression_Constant;
11
use Twig\Node\Expression\NameExpression as Twig_Node_Expression_Name;
12
use Twig\Node\Expression\ArrayExpression as Twig_Node_Expression_Array;;
13
14
/**
15
 * Class MacroContextNodeVisitor.
16
 */
17
class MacroContextNodeVisitor extends Twig_BaseNodeVisitor
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function getPriority()
23
    {
24
        return 0;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
31
    {
32
        // add wrapper instance as argument on all method calls
33
        if ($node instanceof Twig_Node_Expression_MethodCall) {
34
            $keyNode = new Twig_Node_Expression_Constant(PhpSpreadsheetWrapper::INSTANCE_KEY, $node->getTemplateLine());
35
36
            // add wrapper even if it not exists, we fix that later
37
            $valueNode = new Twig_Node_Expression_Name(PhpSpreadsheetWrapper::INSTANCE_KEY, $node->getTemplateLine());
38
            $valueNode->setAttribute('ignore_strict_check', true);
39
40
            /**
41
             * @var Twig_Node_Expression_Array $argumentsNode
42
             */
43
            $argumentsNode = $node->getNode('arguments');
44
            $argumentsNode->addElement($valueNode, $keyNode);
45
        }
46
47
        return $node;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
54
    {
55
        return $node;
56
    }
57
}
58