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

AbstractRadioButtonTwigExtension::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the adminbsb-material-design-bundle package.
5
 *
6
 * (c) 2017 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\Form;
13
14
use WBW\Bundle\AdminBSBBundle\Twig\Extension\AbstractAdminBSBTwigExtension;
15
use WBW\Library\Core\Utility\Argument\StringUtility;
16
17
/**
18
 * Abstract radio button Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\AdminBSBBundle\Twig\Extension\Form
22
 * @abstract
23
 */
24
abstract class AbstractRadioButtonTwigExtension extends AbstractAdminBSBTwigExtension {
25
26
    /**
27
     * Constructor.
28
     */
29
    protected function __construct() {
30
        parent::__construct();
31
    }
32
33
    /**
34
     * Displays a AdminBSB radio button.
35
     *
36
     * @param string $content The content.
37
     * @param string $name The name.
38
     * @param string $id The id.
39
     * @param boolean $checked Checked ?
40
     * @param boolean $disabled Disabled ?
41
     * @param boolean $withGap With gap ?
42
     * @param string $class The class.
43
     * @return string Returns the AdminBSB radio button.
44
     */
45
    protected function adminBSBRadioButton($content, $name, $id, $checked, $disabled, $withGap, $class) {
46
47
        // Initialize the template.
48
        $template = "<input %attributes%>%innerHTML%";
49
50
        // Initialize the attributes.
51
        $attributes = [];
52
53
        $attributes["class"]    = [true === $withGap ? "with-gap" : null, $class];
54
        $attributes["name"]     = $name;
55
        $attributes["type"]     = "radio";
56
        $attributes["id"]       = $id;
57
        $attributes["checked"]  = true === $checked ? "checked" : null;
58
        $attributes["disabled"] = true === $disabled ? "disabled" : null;
59
60
        // Check the parameters.
61
        $innerHTML = self::bootstrapHTMLElement("label", $content, ["for" => $attributes["id"]]);
0 ignored issues
show
Bug introduced by
The method bootstrapHTMLElement() does not seem to exist on object<WBW\Bundle\AdminB...dioButtonTwigExtension>.

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...
62
63
        // Return the HTML.
64
        return StringUtility::replace($template, ["%attributes%", "%innerHTML%"], [StringUtility::parseArray($attributes), $innerHTML]);
65
    }
66
67
}
68