AntiXssNode   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A compile() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace voku\twig;
6
7
use Twig_Node;
8
9
/**
10
 * Class AntiXssNode
11
 */
12
class AntiXssNode extends Twig_Node
13
{
14
  /**
15
   * AntiXssNode constructor.
16
   *
17
   * @param array $nodes
18
   * @param array $attributes
19
   * @param int   $lineno
20
   * @param null  $tag
21
   */
22 2
  public function __construct(array $nodes = [], array $attributes = [], $lineno = 0, $tag = null)
23
  {
24 2
    parent::__construct($nodes, $attributes, $lineno, $tag);
25 2
  }
26
27
  /** @noinspection PhpMissingParentCallCommonInspection */
28
  /**
29
   * @param \Twig_Compiler $compiler
30
   */
31 2
  public function compile(\Twig_Compiler $compiler)
32
  {
33
    $compiler
34 2
        ->addDebugInfo($this)
35 2
        ->write("ob_start();\n")
36 2
        ->subcompile($this->getNode('body'))
37 2
        ->write('$extension = $this->env->getExtension(\'\\voku\\twig\\AntiXssExtension\');' . "\n")
38 2
        ->write('echo $extension->xss_clean(ob_get_clean());' . "\n");
39 2
  }
40
}
41