|
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
|
|
|
/** |
|
15
|
|
|
* Progress bar renderer. |
|
16
|
|
|
* |
|
17
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
18
|
|
|
* @package WBW\Bundle\BootstrapBundle\ProgressBar |
|
19
|
|
|
*/ |
|
20
|
|
|
class ProgressBarRenderer { |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Render an animated. |
|
24
|
|
|
* |
|
25
|
|
|
* @param ProgressBarInterface $progressBar The progress bar. |
|
26
|
|
|
* @return string|null Returns the rendered animated. |
|
27
|
|
|
*/ |
|
28
|
|
|
public static function renderAnimated(ProgressBarInterface $progressBar): ?string { |
|
29
|
|
|
return true === $progressBar->getAnimated() ? "active" : null; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Render a content. |
|
34
|
|
|
* |
|
35
|
|
|
* @param ProgressBarInterface $progressBar The progress bar. |
|
36
|
|
|
* @param string $default The default content. |
|
37
|
|
|
* @return string|null Returns the rendered content. |
|
38
|
|
|
*/ |
|
39
|
|
|
public static function renderContent(ProgressBarInterface $progressBar, string $default): ?string { |
|
40
|
|
|
return null !== $progressBar->getContent() ? $progressBar->getContent() : $default; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Render a striped. |
|
45
|
|
|
* |
|
46
|
|
|
* @param ProgressBarInterface $progressBar The progress bar. |
|
47
|
|
|
* @return string|null Returns the rendered striped. |
|
48
|
|
|
*/ |
|
49
|
|
|
public static function renderStriped(ProgressBarInterface $progressBar): ?string { |
|
50
|
|
|
return true === $progressBar->getStriped() ? "progress-bar-striped" : null; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Render a style. |
|
55
|
|
|
* |
|
56
|
|
|
* @param ProgressBarInterface $progressBar The progress bar. |
|
57
|
|
|
* @return string|null Returns the rendered style. |
|
58
|
|
|
*/ |
|
59
|
|
|
public static function renderStyle(ProgressBarInterface $progressBar): ?string { |
|
60
|
|
|
return null !== $progressBar->getValue() ? "width: " . $progressBar->getValue() . "%;" : null; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Render a type. |
|
65
|
|
|
* |
|
66
|
|
|
* @param ProgressBarInterface $progressBar The progress bar. |
|
67
|
|
|
* @return string|null Returns the rendered type. |
|
68
|
|
|
*/ |
|
69
|
|
|
public static function renderType(ProgressBarInterface $progressBar): ?string { |
|
70
|
|
|
return null !== $progressBar->getType() ? $progressBar->getPrefix() . $progressBar->getType() : null; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|