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.

ForLoopCompiler   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 63
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 4 1
B compile() 0 55 5
1
<?php
2
3
namespace TwigJs\Compiler;
4
5
use TwigJs\JsCompiler;
6
use TwigJs\TypeCompilerInterface;
7
8
class ForLoopCompiler implements TypeCompilerInterface
9
{
10
    public function getType()
11
    {
12
        return 'Twig_Node_ForLoop';
13
    }
14
15
    public function compile(JsCompiler $compiler, \Twig_NodeInterface $node)
16
    {
17
        if (!$node instanceof \Twig_Node_ForLoop) {
18
            throw new \RuntimeException(
19
                sprintf(
20
                    '$node must be an instanceof of \Twig_Node_ForLoop, but got "%s".',
21
                    get_class($node)
22
                )
23
            );
24
        }
25
26
        if ($node->getAttribute('else')) {
27
            $compiler
28
                ->write("")
29
                ->subcompile(new \Twig_Node_Expression_Name('_iterated', $node->getLine()))
0 ignored issues
show
Deprecated Code introduced by
The method Twig_Node::getLine() has been deprecated with message: since 1.27 (to be removed in 2.0)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
30
                ->raw(" = true;\n")
31
            ;
32
        }
33
34
        if ($node->getAttribute('with_loop')) {
35
            $compiler
36
                ->write("++")
37
                ->subcompile(new \Twig_Node_Expression_Name('loop', $node->getLine()))
0 ignored issues
show
Deprecated Code introduced by
The method Twig_Node::getLine() has been deprecated with message: since 1.27 (to be removed in 2.0)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
38
                ->raw("['index0'];\n")
39
                ->write("++")
40
                ->subcompile(new \Twig_Node_Expression_Name('loop', $node->getLine()))
0 ignored issues
show
Deprecated Code introduced by
The method Twig_Node::getLine() has been deprecated with message: since 1.27 (to be removed in 2.0)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
41
                ->raw("['index'];\n")
42
                ->write("")
43
                ->subcompile(new \Twig_Node_Expression_Name('loop', $node->getLine()))
0 ignored issues
show
Deprecated Code introduced by
The method Twig_Node::getLine() has been deprecated with message: since 1.27 (to be removed in 2.0)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
44
                ->raw("['first'] = false;\n")
45
            ;
46
47
            if (!$node->getAttribute('ifexpr')) {
48
                $compiler
49
                    ->write("if (")
50
                    ->subcompile(new \Twig_Node_Expression_Name('loop', $node->getLine()))
0 ignored issues
show
Deprecated Code introduced by
The method Twig_Node::getLine() has been deprecated with message: since 1.27 (to be removed in 2.0)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
51
                    ->raw("['length']) {\n")
52
                    ->indent()
53
                    ->write("--")
54
                    ->subcompile(new \Twig_Node_Expression_Name('loop', $node->getLine()))
0 ignored issues
show
Deprecated Code introduced by
The method Twig_Node::getLine() has been deprecated with message: since 1.27 (to be removed in 2.0)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
55
                    ->raw("['revindex0'];\n")
56
                    ->write("--")
57
                    ->subcompile(new \Twig_Node_Expression_Name('loop', $node->getLine()))
0 ignored issues
show
Deprecated Code introduced by
The method Twig_Node::getLine() has been deprecated with message: since 1.27 (to be removed in 2.0)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
58
                    ->raw("['revindex'];\n")
59
                    ->write("")
60
                    ->subcompile(new \Twig_Node_Expression_Name('loop', $node->getLine()))
0 ignored issues
show
Deprecated Code introduced by
The method Twig_Node::getLine() has been deprecated with message: since 1.27 (to be removed in 2.0)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
61
                    ->raw("['last'] = 0 === ")
62
                    ->subcompile(new \Twig_Node_Expression_Name('loop', $node->getLine()))
0 ignored issues
show
Deprecated Code introduced by
The method Twig_Node::getLine() has been deprecated with message: since 1.27 (to be removed in 2.0)

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
63
                    ->raw("['revindex0'];\n")
64
                    ->outdent()
65
                    ->write("}\n")
66
                ;
67
            }
68
        }
69
    }
70
}
71