HandlebarsTwigExtension::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * @author @jenschude <[email protected]>
4
 */
5
6
namespace JaySDe\HandlebarsBundle\Extension;
7
8
use JaySDe\HandlebarsBundle\HandlebarsEngine;
9
10
class HandlebarsTwigExtension extends \Twig_Extension
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Extension has been deprecated with message: since Twig 2.7, use "Twig\Extension\AbstractExtension" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
11
{
12
    private $engine;
13
14 1
    public function __construct(HandlebarsEngine $environment)
15
    {
16 1
        $this->engine = $environment;
17
18 1
    }
19 1
    public function getFunctions()
20
    {
21
        return [
22 1
            new \Twig_SimpleFunction('render_hbs', [$this, 'renderHandlebars'])
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated with message: since Twig 2.7, use "Twig\TwigFunction" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
23
        ];
24
    }
25
26 1
    public function renderHandlebars($name, array $data = [])
27
    {
28 1
        return $this->engine->render($name, $data);
29
    }
30
31
    public function getName()
32
    {
33
        return 'HandlebarsTwigExtension';
34
    }
35
}
36