AnnotateNode::compile()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
cc 4
eloc 13
c 2
b 1
f 1
nc 8
nop 1
dl 0
loc 21
rs 9.8333
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
namespace Zicht\Bundle\FrameworkExtraBundle\Twig\Meta;
7
8
use Twig_Node;
9
use Twig_Compiler;
10
11
/**
12
 * Class AnnotateNode
13
 *
14
 * @package Zicht\Bundle\FrameworkExtraBundle\Twig\Meta
15
 */
16
class AnnotateNode extends Twig_Node
17
{
18
    /**
19
     * Compile
20
     *
21
     * @param Twig_Compiler $compiler
22
     */
23
    public function compile(Twig_Compiler $compiler)
24
    {
25
        $has_prio = $this->hasNode('prio');
26
        $prio = ($has_prio) ? $this->getNode('prio') : 0 ;
27
        $compiler->addDebugInfo($this);
28
        $compiler->write('$this->env->getExtension(\'zicht_framework_extra\')->getAnnotationRegistry()');
29
30
        if ($this->hasNode('name')) {
31
            $compiler->raw('->addAnnotation(')->subcompile($this->getNode('name'))->raw(', ');
32
        } else {
33
            $compiler->raw('->addAnnotations(');
34
        }
35
36
        $compiler->subcompile($this->getNode('expr'));
37
38
        if ($has_prio) {
39
            $compiler->raw(', ');
40
            $compiler->subcompile($prio);
0 ignored issues
show
Bug introduced by
It seems like $prio can also be of type integer; however, parameter $node of Twig\Compiler::subcompile() does only seem to accept Twig_NodeInterface, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
            $compiler->subcompile(/** @scrutinizer ignore-type */ $prio);
Loading history...
41
        }
42
43
        $compiler->write(');' . "\n");
44
    }
45
}
46