Completed
Push — master ( 7d0ef3...14c63c )
by WEBEWEB
03:01
created

AbstractTypographyTwigExtension   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 120
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 1
dl 0
loc 120
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A bootstrapBold() 0 3 1
A bootstrapDeleted() 0 3 1
A bootstrapHeading() 0 20 4
A bootstrapInserted() 0 3 1
A bootstrapItalic() 0 3 1
A bootstrapMarked() 0 3 1
A bootstrapStrikeThrough() 0 3 1
A bootstrapSmall() 0 3 1
A bootstrapUnderlined() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the bootstrap-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\BootstrapBundle\Twig\Extension\CSS;
13
14
use WBW\Bundle\BootstrapBundle\Twig\Extension\AbstractBootstrapTwigExtension;
15
16
/**
17
 * Abstract typography Twig extension.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\CSS
21
 * @abstract
22
 */
23
abstract class AbstractTypographyTwigExtension extends AbstractBootstrapTwigExtension {
24
25
    /**
26
     * Constructor.
27
     */
28
    protected function __construct() {
29
        parent::__construct();
30
    }
31
32
    /**
33
     * Displays a Bootstrap bold text.
34
     *
35
     * @param string $content The content.
36
     * @return string  Returns the Bootstrap bold text.
37
     */
38
    protected function bootstrapBold($content) {
39
        return self::bootstrapHTMLElement("strong", $content);
40
    }
41
42
    /**
43
     * Displays a Bootstrap deleted text.
44
     *
45
     * @param string $content The content.
46
     * @return string  Returns the Bootstrap deleted text.
47
     */
48
    protected function bootstrapDeleted($content) {
49
        return self::bootstrapHTMLElement("del", $content);
50
    }
51
52
    /**
53
     * Displays a Bootstrap heading.
54
     *
55
     * @param integer $size The size.
56
     * @param string $content The content.
57
     * @param string $description The description.
58
     * @param string $class The class.
59
     * @return string Returns the Bootstrap heading.
60
     */
61
    protected function bootstrapHeading($size, $content, $description, $class) {
62
63
        // Initialize the values.
64
        $sizes = [1, 2, 3, 4, 5, 6];
65
66
        // Initialize the element.
67
        $element = "h" . (true === in_array($size, $sizes) ? $size : 1);
68
69
        // Initialize the attributes.
70
        $attributes = [];
71
72
        $attributes["class"] = [$class];
73
74
        // Initialize the parameters.
75
        $secondary = null !== $description ? " <small>" . $description . "</small>" : "";
76
        $innerHTML = (null !== $content ? $content : "") . $secondary;
77
78
        // Return the HTML.
79
        return self::bootstrapHTMLElement($element, $innerHTML, $attributes);
80
    }
81
82
    /**
83
     * Displays a Bootstrap inserted text.
84
     *
85
     * @param string $content The content.
86
     * @return string  Returns the Bootstrap inserted text.
87
     */
88
    protected function bootstrapInserted($content) {
89
        return self::bootstrapHTMLElement("ins", $content);
90
    }
91
92
    /**
93
     * Displays a Bootstrap italic text.
94
     *
95
     * @param string $content The content.
96
     * @return string  Returns the Bootstrap italic text.
97
     */
98
    protected function bootstrapItalic($content) {
99
        return self::bootstrapHTMLElement("em", $content);
100
    }
101
102
    /**
103
     * Displays a Bootstrap marked text.
104
     *
105
     * @param string $content The content.
106
     * @return string  Returns the Bootstrap marked text.
107
     */
108
    protected function bootstrapMarked($content) {
109
        return self::bootstrapHTMLElement("mark", $content);
110
    }
111
112
    /**
113
     * Displays a Bootstrap strike through text.
114
     *
115
     * @param string $content The content.
116
     * @return string  Returns the Bootstrap strike through text.
117
     */
118
    protected function bootstrapStrikeThrough($content) {
119
        return self::bootstrapHTMLElement("s", $content);
120
    }
121
122
    /**
123
     * Displays a Bootstrap small text.
124
     *
125
     * @param string $content The content.
126
     * @return string  Returns the Bootstrap small text.
127
     */
128
    protected function bootstrapSmall($content) {
129
        return self::bootstrapHTMLElement("small", $content);
130
    }
131
132
    /**
133
     * Displays a Bootstrap underlined text.
134
     *
135
     * @param string $content The content.
136
     * @return string  Returns the Bootstrap underlined text.
137
     */
138
    protected function bootstrapUnderlined($content) {
139
        return self::bootstrapHTMLElement("u", $content);
140
    }
141
142
}
143