Initialize   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 18
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A compile() 0 12 1
1
<?php
2
/*
3
 * This file is part of the Twig Bufferized Template package, an RunOpenCode project.
4
 *
5
 * (c) 2017 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace RunOpenCode\Twig\BufferizedTemplate\Tag\TemplateBuffer;
11
12
use RunOpenCode\Twig\BufferizedTemplate\Buffer\BufferManager;
13
14
/**
15
 * Class Initialize
16
 *
17
 * Initialize buffer manager and start new buffer.
18
 *
19
 * @package RunOpenCode\Twig\BufferizedTemplate\Tag\TemplateBuffer
20
 *
21
 * @internal
22
 */
23
final class Initialize extends \Twig_Node
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28 4
    public function compile(\Twig_Compiler $compiler)
29
    {
30 4
        $compiler->addDebugInfo($this);
31
32
        $compiler
33 4
            ->write(sprintf('%s = new \\%s();', $this->getAttribute('bufferized_context_variable_name'), BufferManager::class))
34 4
            ->write("\n");
35
36
        $compiler
37 4
            ->write(sprintf('%s->bufferize(Closure::bind(function() use (&$context, &$blocks) {', $this->getAttribute('bufferized_context_variable_name')))
38 4
            ->write("\n");
39 4
    }
40
}
41