Completed
Push — master ( 10f697...c17cc0 )
by WEBEWEB
02:43
created

AbstractButtonTwigExtension   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 13
lcom 0
cbo 2
dl 0
loc 52
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
F adminBSBButton() 0 28 12
1
<?php
2
3
/**
4
 * This file is part of the adminbsb-material-design-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\AdminBSBBundle\Twig\Extension\UI;
13
14
use WBW\Bundle\AdminBSBBundle\Twig\Extension\AbstractAdminBSBTwigExtension;
15
use WBW\Bundle\AdminBSBBundle\Twig\Extension\AdminBSBRendererTwigExtension;
16
17
/**
18
 * Abstract button Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\AdminBSBBundle\Twig\Extension\UI
22
 * @abstract
23
 */
24
abstract class AbstractButtonTwigExtension extends AbstractAdminBSBTwigExtension {
25
26
    /**
27
     * Constructor.
28
     */
29
    protected function __construct() {
30
        parent::__construct();
31
    }
32
33
    /**
34
     * Displays an AdminBSB button.
35
     *
36
     * @param string $content The button content.
37
     * @param string $title The button title.
38
     * @param string $size The button size.
39
     * @param boolean $block Block button ?
40
     * @param booelan $disable Disable button ?
41
     * @param string $class The button class.
42
     * @param string $icon The button icon.
43
     * @param boolean $circle Circle button ?
44
     * @return string Returns the AdminBSB button.
45
     */
46
    protected function adminBSBButton($content, $title, $size, $block, $disable, $class, $icon, $circle) {
47
48
        // Disable the parameters.
49
        $circle = null !== $content ? false : $circle;
50
        $style  = null !== $content ? "margin: -4px 2px 0; vertical-align: sub;" : "";
51
52
        // Initialize the values.
53
        $sizes = ["lg", "sm", "xs"];
54
55
        // Initialize the attributes.
56
        $attributes = [];
57
58
        $attributes["class"]       = ["btn", $class, "waves-effect"];
59
        $attributes["class"][]     = true === $block ? "btn-block" : null;
60
        $attributes["class"][]     = true === $circle ? "btn-circle" . ("lg" === $size ? "-lg" : "") . " waves-circle waves-float" : null;
61
        $attributes["class"][]     = true !== $circle && true === in_array($size, $sizes) ? "btn-" . $size : null;
62
        $attributes["title"]       = $title;
63
        $attributes["type"]        = "button";
64
        $attributes["data-toggle"] = null !== $title ? "tooltip" : null;
65
        $attributes["disabled"]    = true === $disable ? "disabled" : null;
66
67
        // Handle the parameters.
68
        $innerHTML = null !== $content ? $content : "";
69
        $glyphicon = null !== $icon ? AdminBSBRendererTwigExtension::renderIcon($icon, $style) : "";
70
71
        // Return the HTML.
72
        return self::bootstrapHTMLElement("button", $glyphicon . $innerHTML, $attributes);
0 ignored issues
show
Bug introduced by
The method bootstrapHTMLElement() does not seem to exist on object<WBW\Bundle\AdminB...actButtonTwigExtension>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
73
    }
74
75
}
76