Completed
Push — master ( 67c65c...9a618a )
by WEBEWEB
06:47
created

LabelComponentTwigExtension   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 8
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 93
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A bootstrapLabelDangerFunction() 0 3 1
A bootstrapLabelDefaultFunction() 0 3 1
A bootstrapLabelInfoFunction() 0 3 1
A bootstrapLabelPrimaryFunction() 0 3 1
A bootstrapLabelSuccessFunction() 0 3 1
A bootstrapLabelWarningFunction() 0 3 1
A getFunctions() 0 10 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\Component;
13
14
use Twig_SimpleFunction;
15
use WBW\Library\Core\Utility\ArrayUtility;
16
17
/**
18
 * Label component Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component
22
 * @final
23
 */
24
final class LabelComponentTwigExtension extends AbstractComponentTwigExtension {
25
26
    /**
27
     * Service name.
28
     *
29
     * @var string
30
     */
31
    const SERVICE_NAME = "webeweb.bundle.bootstrapbundle.twig.extension.component.label";
32
33
    /**
34
     * Constructor.
35
     */
36
    public function __construct() {
37
        parent::__construct();
38
    }
39
40
    /**
41
     * Displays a Bootstrap label "Danger".
42
     *
43
     * @param array $args The arguments.
44
     * @return string Returns the Bootstrap label "Danger".
45
     */
46
    public function bootstrapLabelDangerFunction(array $args = []) {
47
        return $this->bootstrapLabel(ArrayUtility::get($args, "content"), "label-danger");
48
    }
49
50
    /**
51
     * Displays a Bootstrap label "Default".
52
     *
53
     * @param array $args The arguments.
54
     * @return string Returns the Bootstrap label "Default".
55
     */
56
    public function bootstrapLabelDefaultFunction(array $args = []) {
57
        return $this->bootstrapLabel(ArrayUtility::get($args, "content"), "label-default");
58
    }
59
60
    /**
61
     * Displays a Bootstrap label "Info".
62
     *
63
     * @param array $args The arguments.
64
     * @return string Returns the Bootstrap label "Info".
65
     */
66
    public function bootstrapLabelInfoFunction(array $args = []) {
67
        return $this->bootstrapLabel(ArrayUtility::get($args, "content"), "label-info");
68
    }
69
70
    /**
71
     * Displays a Bootstrap label "Primary".
72
     *
73
     * @param array $args The arguments.
74
     * @return string Returns the Bootstrap label "Primary".
75
     */
76
    public function bootstrapLabelPrimaryFunction(array $args = []) {
77
        return $this->bootstrapLabel(ArrayUtility::get($args, "content"), "label-primary");
78
    }
79
80
    /**
81
     * Displays a Bootstrap label "Success".
82
     *
83
     * @param array $args The arguments.
84
     * @return string Returns the Bootstrap label "Success".
85
     */
86
    public function bootstrapLabelSuccessFunction(array $args = []) {
87
        return $this->bootstrapLabel(ArrayUtility::get($args, "content"), "label-success");
88
    }
89
90
    /**
91
     * Displays a Bootstrap label "Warning".
92
     *
93
     * @param array $args The arguments.
94
     * @return string Returns the Bootstrap label "Warning".
95
     */
96
    public function bootstrapLabelWarningFunction(array $args = []) {
97
        return $this->bootstrapLabel(ArrayUtility::get($args, "content"), "label-warning");
98
    }
99
100
    /**
101
     * Get the Twig functions.
102
     *
103
     * @return Twig_SimpleFunction[] Returns the Twig functions.
104
     */
105
    public function getFunctions() {
106
        return [
107
            new Twig_SimpleFunction("bootstrapLabelDanger", [$this, "bootstrapLabelDangerFunction"], ["is_safe" => ["html"]]),
108
            new Twig_SimpleFunction("bootstrapLabelDefault", [$this, "bootstrapLabelDefaultFunction"], ["is_safe" => ["html"]]),
109
            new Twig_SimpleFunction("bootstrapLabelInfo", [$this, "bootstrapLabelInfoFunction"], ["is_safe" => ["html"]]),
110
            new Twig_SimpleFunction("bootstrapLabelPrimary", [$this, "bootstrapLabelPrimaryFunction"], ["is_safe" => ["html"]]),
111
            new Twig_SimpleFunction("bootstrapLabelSuccess", [$this, "bootstrapLabelSuccessFunction"], ["is_safe" => ["html"]]),
112
            new Twig_SimpleFunction("bootstrapLabelWarning", [$this, "bootstrapLabelWarningFunction"], ["is_safe" => ["html"]]),
113
        ];
114
    }
115
116
}
117