ProgressBarFactory::newWarningProgressBar()   A
last analyzed

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 bootstrap-bundle package.
5
 *
6
 * (c) 2019 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\ProgressBar;
13
14
use WBW\Library\Core\Argument\Helper\ArrayHelper;
15
16
/**
17
 * Progress bar factory.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\BootstrapBundle\ProgressBar
21
 */
22
class ProgressBarFactory {
23
24
    /**
25
     * Creates a new basic progress bar.
26
     *
27
     * @return ProgressBarInterface Returns the success progress bar.
28
     */
29
    public static function newBasicProgressBar(): ProgressBarInterface {
30
        return new BasicProgressBar();
31
    }
32
33
    /**
34
     * Creates a new danger progress bar.
35
     *
36
     * @return ProgressBarInterface Returns the danger progress bar.
37
     */
38
    public static function newDangerProgressBar(): ProgressBarInterface {
39
        return new DangerProgressBar();
40
    }
41
42
    /**
43
     * Creates a new info progress bar.
44
     *
45
     * @return ProgressBarInterface Returns the info progress bar.
46
     */
47
    public static function newInfoProgressBar(): ProgressBarInterface {
48
        return new InfoProgressBar();
49
    }
50
51
    /**
52
     * Creates a new success progress bar.
53
     *
54
     * @return ProgressBarInterface Returns the success progress bar.
55
     */
56
    public static function newSuccessProgressBar(): ProgressBarInterface {
57
        return new SuccessProgressBar();
58
    }
59
60
    /**
61
     * Creates a new warning progress bar.
62
     *
63
     * @return ProgressBarInterface Returns the warning progress bar.
64
     */
65
    public static function newWarningProgressBar(): ProgressBarInterface {
66
        return new WarningProgressBar();
67
    }
68
69
    /**
70
     * Parse a basic progress bar.
71
     *
72
     * @param array $args The arguments.
73
     * @return ProgressBarInterface Returns the basic progress bar.
74
     */
75
    public static function parseBasicProgressBar(array $args): ProgressBarInterface {
76
        return static::parseProgressBar(static::newBasicProgressBar(), $args);
77
    }
78
79
    /**
80
     * Parse a danger progress bar.
81
     *
82
     * @param array $args The arguments.
83
     * @return ProgressBarInterface Returns the danger progress bar.
84
     */
85
    public static function parseDangerProgressBar(array $args): ProgressBarInterface {
86
        return static::parseProgressBar(static::newDangerProgressBar(), $args);
87
    }
88
89
    /**
90
     * Parse a info progress bar.
91
     *
92
     * @param array $args The arguments.
93
     * @return ProgressBarInterface Returns the info progress bar.
94
     */
95
    public static function parseInfoProgressBar(array $args): ProgressBarInterface {
96
        return static::parseProgressBar(static::newInfoProgressBar(), $args);
97
    }
98
99
    /**
100
     * Parses a progress bar.
101
     *
102
     * @param ProgressBarInterface $progressBar The progress bar.
103
     * @param array $args The arguments.
104
     * @return ProgressBarInterface Returns the progress bar.
105
     */
106
    protected static function parseProgressBar(ProgressBarInterface $progressBar, array $args): ProgressBarInterface {
107
108
        $progressBar->setAnimated(ArrayHelper::get($args, "animated", false));
109
        $progressBar->setContent(ArrayHelper::get($args, "content"));
110
        $progressBar->setHeight(ArrayHelper::get($args, "height"));
111
        $progressBar->setMax(ArrayHelper::get($args, "max", 100));
112
        $progressBar->setMin(ArrayHelper::get($args, "min", 0));
113
        $progressBar->setStriped(ArrayHelper::get($args, "striped", false));
114
        $progressBar->setValue(ArrayHelper::get($args, "value", 50));
115
116
        return $progressBar;
117
    }
118
119
    /**
120
     * Parse a success progress bar.
121
     *
122
     * @param array $args The arguments.
123
     * @return ProgressBarInterface Returns the success progress bar.
124
     */
125
    public static function parseSuccessProgressBar(array $args): ProgressBarInterface {
126
        return static::parseProgressBar(static::newSuccessProgressBar(), $args);
127
    }
128
129
    /**
130
     * Parse a warning progress bar.
131
     *
132
     * @param array $args The arguments.
133
     * @return ProgressBarInterface Returns the warning progress bar.
134
     */
135
    public static function parseWarningProgressBar(array $args): ProgressBarInterface {
136
        return static::parseProgressBar(static::newWarningProgressBar(), $args);
137
    }
138
}
139