Completed
Push — master ( 4d5688...be014c )
by WEBEWEB
01:51
created

ProgressBarTwigExtension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A bootstrapProgressBarBasicFunction() 0 3 1
A bootstrapProgressBarDangerFunction() 0 3 1
A bootstrapProgressBarInfoFunction() 0 3 1
A bootstrapProgressBarSuccessFunction() 0 3 1
A bootstrapProgressBarWarningFunction() 0 3 1
A getFunctions() 0 18 1
1
<?php
2
3
/*
4
 * This file is part of the bootstrap-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\BootstrapBundle\Twig\Extension\Component;
13
14
use Twig_SimpleFunction;
15
use WBW\Bundle\BootstrapBundle\BootstrapBundle;
16
use WBW\Library\Core\Argument\ArrayHelper;
17
18
/**
19
 * Progress bar Twig extension.
20
 *
21
 * @author webeweb <https://github.com/webeweb/>
22
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component
23
 * @link https://getbootstrap.com/docs/3.3/components/#progress
24
 */
25
class ProgressBarTwigExtension extends AbstractProgressBarTwigExtension {
26
27
    /**
28
     * Service name.
29
     *
30
     * @var string
31
     */
32
    const SERVICE_NAME = "webeweb.bootstrap.twig.extension.component.progress_bar";
33
34
    /**
35
     * Displays a Bootstrap progress bar "Basic".
36
     *
37
     * @param array $args The arguments.
38
     * @return string Returns the Bootstrap progress bar "Basic".
39
     */
40
    public function bootstrapProgressBarBasicFunction(array $args = []) {
41
        return $this->bootstrapProgressBar(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "value", 50), ArrayHelper::get($args, "min", 0), ArrayHelper::get($args, "max", 100), ArrayHelper::get($args, "striped", false), ArrayHelper::get($args, "animated", false));
42
    }
43
44
    /**
45
     * Displays a Bootstrap progress bar "Danger".
46
     *
47
     * @param array $args The arguments.
48
     * @return string Returns the Bootstrap progress bar "Danger".
49
     */
50
    public function bootstrapProgressBarDangerFunction(array $args = []) {
51
        return $this->bootstrapProgressBar(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "value", 50), ArrayHelper::get($args, "min", 0), ArrayHelper::get($args, "max", 100), ArrayHelper::get($args, "striped", false), ArrayHelper::get($args, "animated", false), "progress-bar-" . BootstrapBundle::BOOTSTRAP_DANGER);
52
    }
53
54
    /**
55
     * Displays a Bootstrap progress bar "Info".
56
     *
57
     * @param array $args The arguments.
58
     * @return string Returns the Bootstrap progress bar "Info".
59
     */
60
    public function bootstrapProgressBarInfoFunction(array $args = []) {
61
        return $this->bootstrapProgressBar(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "value", 50), ArrayHelper::get($args, "min", 0), ArrayHelper::get($args, "max", 100), ArrayHelper::get($args, "striped", false), ArrayHelper::get($args, "animated", false), "progress-bar-" . BootstrapBundle::BOOTSTRAP_INFO);
62
    }
63
64
    /**
65
     * Displays a Bootstrap progress bar "Success".
66
     *
67
     * @param array $args The arguments.
68
     * @return string Returns the Bootstrap progress bar "Success".
69
     */
70
    public function bootstrapProgressBarSuccessFunction(array $args = []) {
71
        return $this->bootstrapProgressBar(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "value", 50), ArrayHelper::get($args, "min", 0), ArrayHelper::get($args, "max", 100), ArrayHelper::get($args, "striped", false), ArrayHelper::get($args, "animated", false), "progress-bar-" . BootstrapBundle::BOOTSTRAP_SUCCESS);
72
    }
73
74
    /**
75
     * Displays a Bootstrap progress bar "Warning".
76
     *
77
     * @param array $args The arguments.
78
     * @return string Returns the Bootstrap progress bar "Warning".
79
     */
80
    public function bootstrapProgressBarWarningFunction(array $args = []) {
81
        return $this->bootstrapProgressBar(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "value", 50), ArrayHelper::get($args, "min", 0), ArrayHelper::get($args, "max", 100), ArrayHelper::get($args, "striped", false), ArrayHelper::get($args, "animated", false), "progress-bar-" . BootstrapBundle::BOOTSTRAP_WARNING);
82
    }
83
84
    /**
85
     * Get the Twig functions.
86
     *
87
     * @return Twig_SimpleFunction[] Returns the Twig functions.
88
     */
89
    public function getFunctions() {
90
        return [
91
            new Twig_SimpleFunction("bootstrapProgressBarBasic", [$this, "bootstrapProgressBarBasicFunction"], ["is_safe" => ["html"]]),
92
            new Twig_SimpleFunction("bsProgressBarBasic", [$this, "bootstrapProgressBarBasicFunction"], ["is_safe" => ["html"]]),
93
94
            new Twig_SimpleFunction("bootstrapProgressBarDanger", [$this, "bootstrapProgressBarDangerFunction"], ["is_safe" => ["html"]]),
95
            new Twig_SimpleFunction("bsProgressBarDanger", [$this, "bootstrapProgressBarDangerFunction"], ["is_safe" => ["html"]]),
96
97
            new Twig_SimpleFunction("bootstrapProgressBarInfo", [$this, "bootstrapProgressBarInfoFunction"], ["is_safe" => ["html"]]),
98
            new Twig_SimpleFunction("bsProgressBarInfo", [$this, "bootstrapProgressBarInfoFunction"], ["is_safe" => ["html"]]),
99
100
            new Twig_SimpleFunction("bootstrapProgressBarSuccess", [$this, "bootstrapProgressBarSuccessFunction"], ["is_safe" => ["html"]]),
101
            new Twig_SimpleFunction("bsProgressBarSuccess", [$this, "bootstrapProgressBarSuccessFunction"], ["is_safe" => ["html"]]),
102
103
            new Twig_SimpleFunction("bootstrapProgressBarWarning", [$this, "bootstrapProgressBarWarningFunction"], ["is_safe" => ["html"]]),
104
            new Twig_SimpleFunction("bsProgressBarWarning", [$this, "bootstrapProgressBarWarningFunction"], ["is_safe" => ["html"]]),
105
        ];
106
    }
107
}
108