This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Ajax\bootstrap\html; |
||
4 | |||
5 | use Ajax\bootstrap\html\base\HtmlBsDoubleElement; |
||
6 | use Ajax\JsUtils; |
||
7 | |||
8 | use Ajax\bootstrap\html\base\CssRef; |
||
9 | use Ajax\service\JArray; |
||
10 | |||
11 | class HtmlProgressbar extends HtmlBsDoubleElement { |
||
12 | protected $value; |
||
13 | protected $max; |
||
14 | protected $min; |
||
15 | protected $striped=""; |
||
16 | protected $active; |
||
17 | protected $caption; |
||
18 | protected $isStacked=false; |
||
19 | protected $style=""; |
||
20 | protected $styleLimits=null; |
||
21 | |||
22 | public function __construct($identifier, $style="info", $value=0, $max=100, $min=0) { |
||
23 | parent::__construct($identifier); |
||
24 | $this->_template=include 'templates/tplProgressbar.php'; |
||
25 | $this->value=$value; |
||
26 | $this->min=$min; |
||
27 | $this->max=$max; |
||
28 | $this->setStyle($style); |
||
29 | } |
||
30 | |||
31 | View Code Duplication | public function setActive($value) { |
|
0 ignored issues
–
show
|
|||
32 | if(is_array($this->content)){ |
||
33 | foreach ($this->content as $pb){ |
||
34 | $pb->setActive($value); |
||
35 | } |
||
36 | }else{ |
||
37 | if ($value===true) |
||
38 | $this->active="active"; |
||
39 | else |
||
40 | $this->active=""; |
||
41 | } |
||
42 | return $this; |
||
43 | } |
||
44 | |||
45 | public function setStriped($value) { |
||
46 | if(is_array($this->content)){ |
||
47 | foreach ($this->content as $pb){ |
||
48 | $pb->setStriped($value); |
||
49 | } |
||
50 | }else{ |
||
51 | if ($value===true) |
||
52 | $this->striped="progress-bar-striped"; |
||
53 | else |
||
54 | $this->striped=""; |
||
55 | } |
||
56 | return $this; |
||
57 | } |
||
58 | |||
59 | View Code Duplication | public function showCaption($value) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
60 | if(is_array($this->content)){ |
||
61 | foreach ($this->content as $pb){ |
||
62 | $pb->showCaption($value); |
||
63 | } |
||
64 | }else{ |
||
65 | if ($value===true) |
||
66 | $this->caption="%value%%"; |
||
67 | else |
||
68 | $this->caption='<span class="sr-only">%value%% Complete (%style%)</span>'; |
||
69 | } |
||
70 | return $this; |
||
71 | } |
||
72 | |||
73 | public function getValue() { |
||
74 | return $this->value; |
||
75 | } |
||
76 | |||
77 | public function stack(HtmlProgressbar $progressBar) { |
||
78 | $this->_template='%content%'; |
||
79 | $progressBar->setIsStacked(true); |
||
80 | $progressBar->showCaption($this->caption=="%value%%"); |
||
81 | $progressBar->setStriped($this->striped!=="" || $progressBar->isStriped()); |
||
82 | $progressBar->setActive($this->active==="active" || $progressBar->isActive()); |
||
83 | if (is_array($this->content)===false) { |
||
84 | $this->content=array (); |
||
85 | } |
||
86 | $this->content []=$progressBar; |
||
87 | } |
||
88 | |||
89 | public function setValue($value) { |
||
90 | $this->value=$value; |
||
91 | return $this; |
||
92 | } |
||
93 | |||
94 | public function getMax() { |
||
95 | return $this->max; |
||
96 | } |
||
97 | |||
98 | public function setMax($max) { |
||
99 | $this->max=$max; |
||
100 | return $this; |
||
101 | } |
||
102 | |||
103 | public function getMin() { |
||
104 | return $this->min; |
||
105 | } |
||
106 | |||
107 | public function setMin($min) { |
||
108 | $this->min=$min; |
||
109 | return $this; |
||
110 | } |
||
111 | |||
112 | public function getIsStacked() { |
||
113 | return $this->isStacked; |
||
114 | } |
||
115 | |||
116 | public function setIsStacked($isStacked) { |
||
117 | $this->isStacked=$isStacked; |
||
118 | return $this; |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * define the progressbar style |
||
123 | * avaible values : "success","info","warning","danger" |
||
124 | * @param string|int $cssStyle |
||
125 | * @return \Ajax\bootstrap\html\HtmlProgressbar default : "" |
||
126 | */ |
||
127 | public function setStyle($cssStyle) { |
||
128 | return $this->setMemberCtrl($this->style,CssRef::getStyle($cssStyle, "progress-bar"), CssRef::Styles("progress-bar")); |
||
129 | } |
||
130 | |||
131 | /* |
||
132 | * (non-PHPdoc) |
||
133 | * @see \Ajax\bootstrap\html\base\BaseHtml::compile() |
||
134 | */ |
||
135 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
||
136 | $actualStyle=$this->style; |
||
137 | if(isset($this->styleLimits)&& JArray::isAssociative($this->styleLimits)){ |
||
138 | foreach ($this->styleLimits as $k=>$v){ |
||
139 | $actualStyle=$k; |
||
140 | if($v>$this->value) |
||
141 | break; |
||
142 | } |
||
143 | } |
||
144 | $this->style=$actualStyle; |
||
0 ignored issues
–
show
It seems like
$actualStyle can also be of type integer . However, the property $style is declared as type string . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||
145 | $this->_template=str_replace("%caption%", $this->caption, $this->_template); |
||
146 | if ($this->getIsStacked()===false) { |
||
147 | $this->wrap('<div class="progress">', '</div>'); |
||
148 | } |
||
149 | return parent::compile($js, $view); |
||
150 | } |
||
151 | |||
152 | public function isStriped() { |
||
153 | return $this->striped; |
||
154 | } |
||
155 | |||
156 | public function isActive() { |
||
157 | return $this->active; |
||
158 | } |
||
159 | |||
160 | /* (non-PHPdoc) |
||
161 | * @see \Ajax\bootstrap\html\base\BaseHtml::fromDatabaseObject() |
||
162 | */ |
||
163 | public function fromDatabaseObject($object, $function) { |
||
164 | $this->stack($function($object)); |
||
165 | } |
||
166 | |||
167 | public function getStyleLimits() { |
||
168 | return $this->styleLimits; |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * Permet de modifier le style de la progressbar à partir de sa valeur actuelle |
||
173 | * $styleLimits est de la forme ["success"=>50, "warning"=>100] pour obtenir un style success de 0 à 50 et warning de 50 à 100 |
||
174 | * @param array $styleLimits tableau associatif des couples style=>valeur possibles |
||
175 | * @return \Ajax\bootstrap\html\HtmlProgressbar |
||
176 | */ |
||
177 | public function setStyleLimits($styleLimits) { |
||
178 | $this->styleLimits=$styleLimits; |
||
179 | return $this; |
||
180 | } |
||
181 | |||
182 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.