EvaluateFilter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 6 1
A get() 0 9 1
1
<?php
2
3
namespace BZIon\Twig;
4
5
/**
6
 * A Twig filter that takes a string Twig template and an array for context and renders it.
7
 *
8
 * i.e. A Twig filter to render Twig from inside of Twig
9
 */
10
class EvaluateFilter
11
{
12 1
    public function __invoke(\Twig_Environment $env, $string, array $context)
13
    {
14 1
        $template = $env->createTemplate($string);
15
16 1
        return $template->render($context);
17
    }
18
19 1
    public static function get()
20
    {
21 1
        return new \Twig_SimpleFilter('evaluate', new self(), [
22 1
            'needs_environment' => true,
23
            'is_safe' => [
24
                'evaluate' => true
25
            ]
26
        ]);
27
    }
28
}
29