AnnotationsNode   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
c 1
b 0
f 1
dl 0
loc 21
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A compile() 0 14 1
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 AnnotationsNode
13
 *
14
 * @package Zicht\Bundle\FrameworkExtraBundle\Twig\Meta
15
 */
16
class AnnotationsNode extends Twig_Node
17
{
18
    /**
19
     * Compile
20
     *
21
     * @param Twig_Compiler $compiler
22
     */
23
    public function compile(Twig_Compiler $compiler)
24
    {
25
        $compiler->addDebugInfo($this);
26
27
        $compiler
28
            ->write('$parent = $context;')
29
            ->write('foreach ($this->env->getExtension(\'zicht_framework_extra\')->getAnnotationRegistry()->getAnnotations() as $annotation) {')
30
            ->indent()
31
                ->write('$context[\'name\'] = $annotation[\'name\'];')
32
                ->write('$context[\'value\'] = $annotation[\'value\'];')
33
                ->subcompile($this->getNode('body'))
34
            ->outdent()
35
            ->write('}');
36
        $compiler->write('$context = $parent;');
37
    }
38
}
39