AbstractTwigExtension::coreHtmlElement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\CoreBundle\Twig\Extension;
13
14
use Twig\Environment;
15
use Twig\Extension\AbstractExtension;
16
use WBW\Bundle\CoreBundle\Twig\Environment\TwigEnvironmentTrait;
17
use WBW\Library\Symfony\Assets\NavigationNodeInterface;
18
use WBW\Library\Types\Helper\StringHelper;
19
20
/**
21
 * Abstract Twig extension.
22
 *
23
 * @author webeweb <https://github.com/webeweb>
24
 * @package WBW\Bundle\CoreBundle\Twig\Extension
25
 * @abstract
26
 */
27
abstract class AbstractTwigExtension extends AbstractExtension {
28
29 1
    use TwigEnvironmentTrait;
30
31
    /**
32
     * Default content.
33
     *
34
     * @var string
35
     */
36
    const DEFAULT_CONTENT = "&nbsp;";
37
38
    /**
39
     * Default href.
40
     *
41
     * @var string
42
     */
43
    const DEFAULT_HREF = NavigationNodeInterface::DEFAULT_HREF;
44
45
    /**
46
     * Constructor.
47
     *
48
     * @param Environment $twigEnvironment The Twig environment.
49
     */
50 1620
    public function __construct(Environment $twigEnvironment) {
51 1620
        $this->setTwigEnvironment($twigEnvironment);
52 1620
    }
53
54
    /**
55
     * Display an HTML element.
56
     *
57
     * @param string $element The object.
58
     * @param string|null $content The content.
59
     * @param array $attrs The attributes.
60
     * @return string Returns the HTML element.
61
     */
62 440
    public static function coreHtmlElement(string $element, ?string $content, array $attrs = []): string {
63 440
        return StringHelper::domNode($element, $content, $attrs);
64
    }
65
}
66