Completed
Push — master ( dda990...bade66 )
by Nathan
07:38
created

EasyHtmlElementExtension::getFunctions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace NatePage\EasyHtmlElement\Bridge\Twig;
4
5
use NatePage\EasyHtmlElement\HtmlElementInterface;
6
use NatePage\EasyHtmlElement\ElementInterface;
7
8
class EasyHtmlElementExtension extends \Twig_Extension
9
{
10
    /** @var HtmlElementInterface */
11
    private $htmlElement;
12
13
    public function __construct(HtmlElementInterface $htmlElement)
14
    {
15
        $this->htmlElement = $htmlElement;
16
    }
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function getFunctions(): array
22
    {
23
        return array(
24
            new \Twig_Function('htmlElement', array($this, 'load'))
25
        );
26
    }
27
28
    /**
29
     * Load a html element.
30
     *
31
     * @param string|array $name       The element name
32
     * @param array        $parameters The element parameters
33
     * @param array        $attributes The element attributes
34
     * @param array        $children   The element children
35
     *
36
     * @return ElementInterface
37
     */
38
    public function load(
39
        $name,
40
        array $parameters = array(),
41
        array $attributes = array(),
42
        array $children = array()
43
    ): ElementInterface
44
    {
45
        return $this->htmlElement->load($name, $parameters, $attributes, $children);
46
    }
47
}
48