Completed
Push — master ( 86e6cd...995981 )
by WEBEWEB
02:02
created

SwitchButtonTwigExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A adminBSBSwitchButtonBasicFunction() 0 3 1
A adminBSBSwitchButtonMaterialDesignFunction() 0 3 1
A getFunctions() 0 6 1
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 Twig_SimpleFunction;
15
use WBW\Bundle\AdminBSBBundle\Twig\Extension\AbstractAdminBSBTwigExtension;
16
use WBW\Library\Core\Utility\Argument\ArrayUtility;
17
18
/**
19
 * Switch button Twig extension.
20
 *
21
 * @author webeweb <https://github.com/webeweb/>
22
 * @package WBW\Bundle\AdminBSBBundle\Twig\Extension\Form
23
 */
24
class SwitchButtonTwigExtension extends AbstractFormTwigExtension {
25
26
    /**
27
     * Service name.
28
     *
29
     * @var string
30
     */
31
    const SERVICE_NAME = "webeweb.adminbsbbundle.twig.extension.form.switchbutton";
32
33
    /**
34
     * Constructor.
35
     */
36
    public function __construct() {
37
        parent::__construct();
38
    }
39
40
    /**
41
     * Displays an AdminBSB switch button "Basic".
42
     *
43
     * @param array $args The arguments.
44
     * @return string Returns the AdminBSB switch button "Basic".
45
     */
46
    public function adminBSBSwitchButtonBasicFunction(array $args = []) {
47
        return $this->adminBSBSwitchButton(ArrayUtility::get($args, "offLabel"), ArrayUtility::get($args, "name"), ArrayUtility::get($args, "checked", false), ArrayUtility::get($args, "disabled", false), ArrayUtility::get($args, "onLabel"), ArrayUtility::get($args, "attr", []));
48
    }
49
50
    /**
51
     * Displays an AdminBSB switch button "Material design".
52
     *
53
     * @param array $args The arguments.
54
     * @return string Returns the AdminBSB switch button "Material Design".
55
     */
56
    public function adminBSBSwitchButtonMaterialDesignFunction(array $args = []) {
57
        return $this->adminBSBSwitchButton(ArrayUtility::get($args, "offLabel"), ArrayUtility::get($args, "name"), ArrayUtility::get($args, "checked", false), ArrayUtility::get($args, "disabled", false), ArrayUtility::get($args, "onLabel"), ArrayUtility::get($args, "attr", []), AbstractAdminBSBTwigExtension::fixColor(ArrayUtility::get($args, "color", "red"), " switch-col-"));
58
    }
59
60
    /**
61
     * Get the Twig functions.
62
     *
63
     * @return array Returns the Twig functions.
64
     */
65
    public function getFunctions() {
66
        return [
67
            new Twig_SimpleFunction("adminBSBSwitchButtonBasic", [$this, "adminBSBSwitchButtonBasicFunction"], ["is_safe" => ["html"]]),
68
            new Twig_SimpleFunction("adminBSBSwitchButtonMaterialDesign", [$this, "adminBSBSwitchButtonMaterialDesignFunction"], ["is_safe" => ["html"]]),
69
        ];
70
    }
71
72
}
73