Completed
Push — master ( 70556f...49fe65 )
by WEBEWEB
03:56
created

AbstractBootstrapTwigExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A bootstrapSimpleTag() 0 11 2
1
<?php
2
3
/**
4
 * This file is part of the bootstrap-bundle package.
5
 *
6
 * (c) 2018 NdC/WBW
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\BootstrapBundle\Twig\Extension;
13
14
use Twig_Extension;
15
use WBW\Library\Core\Navigation\NavigationInterface;
16
use WBW\Library\Core\Utility\StringUtility;
17
18
/**
19
 * Abstract Bootstrap Twig extension.
20
 *
21
 * @author NdC/WBW <https://github.com/webeweb/>
22
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension
23
 * @abstract
24
 */
25
abstract class AbstractBootstrapTwigExtension extends Twig_Extension {
26
27
    /**
28
     * Default content.
29
     *
30
     * @var string
31
     */
32
    const DEFAULT_CONTENT = "&nbsp;";
33
34
    /**
35
     * Default href.
36
     *
37
     * @var string
38
     */
39
    const DEFAULT_HREF = NavigationInterface::DEFAULT_HREF;
40
41
    /**
42
     * Displays a Bootstrap simple tag.
43
     *
44
     * @param string $name The tag name.
45
     * @param string $content The tag content
46
     * @return string Returns the Bootstrap tag.
47
     */
48
    final protected function bootstrapSimpleTag($name, $content) {
49
50
        // Initialize the template.
51
        $template = "<" . $name . ">%innerHTML%</" . $name . ">";
52
53
        // Initialize the parameters.
54
        $innerHTML = null !== $content ? $content : "";
55
56
        // Return the HTML.
57
        return StringUtility::replace($template, ["%innerHTML%"], [$innerHTML]);
58
    }
59
60
}
61