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

AbstractButtonGroupTwigExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A bootstrapButtonGroup() 0 14 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 WBW\Bundle\BootstrapBundle\Twig\Extension\AbstractBootstrapTwigExtension;
15
16
/**
17
 * Abstract button group Twig extension.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component
21
 * @abstract
22
 */
23
abstract class AbstractButtonGroupTwigExtension extends AbstractBootstrapTwigExtension {
24
25
    /**
26
     * Constructor.
27
     */
28
    protected function __construct() {
29
        parent::__construct();
30
    }
31
32
    /**
33
     * Displays a Bootstrap button group.
34
     *
35
     * @param string $class The class.
36
     * @param string $role The role.
37
     * @param array $buttons The buttons.
38
     * @return string Returns the Bootstrap button group.
39
     */
40
    protected function bootstrapButtonGroup($class, $role, array $buttons) {
41
42
        // Initialize the attributes.
43
        $attributes = [];
44
45
        $attributes["class"] = $class;
46
        $attributes["role"]  = $role;
47
48
        // Initialize the parameters.
49
        $innerHTML = "\n" . implode("\n", $buttons) . "\n";
50
51
        // Return the HTML.
52
        return self::bootstrapHTMLElement("div", $innerHTML, $attributes);
53
    }
54
55
}
56