SwitchButtonTwigExtension   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

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