Completed
Push — master ( 8d8bfa...591466 )
by WEBEWEB
14:10
created

ProgressBarUITwigExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A adminBSBMaterialDesignProgressBarFunction() 0 3 1
A getFunctions() 0 10 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\UI;
13
14
use Twig_SimpleFunction;
15
use WBW\Bundle\AdminBSBBundle\Twig\Extension\AbstractABSBMDTwigExtension;
16
use WBW\Bundle\BootstrapBundle\Twig\Extension\Component\ProgressBarComponentTwigExtension as BaseUITwigExtension;
17
use WBW\Library\Core\Utility\Argument\ArrayUtility;
18
19
/**
20
 * Progress bar UI Twig extension.
21
 *
22
 * @author webeweb <https://github.com/webeweb/>
23
 * @package WBW\Bundle\AdminBSBBundle\Twig\Extension\UI
24
 */
25
class ProgressBarUITwigExtension extends BaseUITwigExtension {
26
27
    /**
28
     * Service name.
29
     *
30
     * @var string
31
     */
32
    const SERVICE_NAME = "webeweb.bundle.adminbsbbundle.twig.extension.ui.progressbar";
33
34
    /**
35
     * Constructor.
36
     */
37
    public function __construct() {
38
        parent::__construct();
39
    }
40
41
    /**
42
     * Displays an AdminBSB material design progress bar.
43
     *
44
     * @param array $args The arguments.
45
     * @return string Returns the AdminBSB material design progress bar.
46
     */
47
    public function adminBSBMaterialDesignProgressBarFunction(array $args = []) {
48
        return $this->bootstrapProgressBar(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "value", 50), ArrayUtility::get($args, "min", 0), ArrayUtility::get($args, "max", 100), ArrayUtility::get($args, "striped", false), ArrayUtility::get($args, "animated", false), AbstractABSBMDTwigExtension::fixColor(ArrayUtility::get($args, "color", "red"), "bg-"));
49
    }
50
51
    /**
52
     * Get the Twig functions.
53
     *
54
     * @return array Returns the Twig functions.
55
     */
56
    public function getFunctions() {
57
        return [
58
            new Twig_SimpleFunction("adminBSBBasicProgressBar", [$this, "bootstrapBasicProgressBarFunction"], ["is_safe" => ["html"]]),
59
            new Twig_SimpleFunction("adminBSBProgressBarDanger", [$this, "bootstrapProgressBarDangerFunction"], ["is_safe" => ["html"]]),
60
            new Twig_SimpleFunction("adminBSBProgressBarInfo", [$this, "bootstrapProgressBarInfoFunction"], ["is_safe" => ["html"]]),
61
            new Twig_SimpleFunction("adminBSBProgressBarSuccess", [$this, "bootstrapProgressBarSuccessFunction"], ["is_safe" => ["html"]]),
62
            new Twig_SimpleFunction("adminBSBProgressBarWarning", [$this, "bootstrapProgressBarWarningFunction"], ["is_safe" => ["html"]]),
63
            new Twig_SimpleFunction("adminBSBMaterialDesignProgressBar", [$this, "adminBSBMaterialDesignProgressBarFunction"], ["is_safe" => ["html"]]),
64
        ];
65
    }
66
67
}
68