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 | * @company MTE Telecom, Ltd. |
||
4 | * @author Ushkov Nikolai <[email protected]> |
||
5 | * Date: 18.04.16 |
||
6 | * Time: 17:16 |
||
7 | */ |
||
8 | |||
9 | namespace Nnx\DataGrid\Button; |
||
10 | |||
11 | /** |
||
12 | * Class AbstractButton |
||
13 | * @package Nnx\DataGrid\Button |
||
14 | */ |
||
15 | abstract class AbstractButton implements ButtonInterface |
||
16 | { |
||
17 | /** |
||
18 | * Наименование кнопки. |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $name; |
||
22 | |||
23 | /** |
||
24 | * url кнопки |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $url; |
||
28 | |||
29 | /** |
||
30 | * Заголовок кнопки |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $title; |
||
34 | |||
35 | /** |
||
36 | * JS код кнопки |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $js; |
||
0 ignored issues
–
show
|
|||
40 | |||
41 | /** |
||
42 | * JS библиотеки кнопки |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $libJs = []; |
||
46 | |||
47 | /** |
||
48 | * Опции кнопки |
||
49 | * @var array | \Traversable |
||
50 | */ |
||
51 | protected $options = []; |
||
52 | |||
53 | /** |
||
54 | * Атрибуты кнопки |
||
55 | * @var array | \Traversable |
||
56 | */ |
||
57 | protected $attributes = []; |
||
58 | |||
59 | /** |
||
60 | * По данному полю осуществляется сортировка кнопок при выводе |
||
61 | * @var int |
||
62 | */ |
||
63 | protected $order = 0; |
||
64 | |||
65 | /** |
||
66 | * Устанавливает свойства класса |
||
67 | * @param string $key |
||
68 | * @param array $options |
||
69 | */ |
||
70 | View Code Duplication | protected function setProperty($key, &$options) |
|
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. ![]() |
|||
71 | { |
||
72 | if (array_key_exists($key, $options)) { |
||
73 | $setter = 'set' . ucfirst($key); |
||
74 | if (method_exists($this, $setter)) { |
||
75 | $this->$setter($options[$key]); |
||
76 | unset($options[$key]); |
||
77 | } |
||
78 | } |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @param $options |
||
83 | */ |
||
84 | public function __construct($options) |
||
85 | { |
||
86 | unset($options['type']); |
||
87 | if (!empty($options['attributes']) && $this->getAttributes()) { |
||
88 | $this->setAttributes(array_merge($this->getAttributes(), $options['attributes'])); |
||
89 | unset($options['attributes']); |
||
90 | } |
||
91 | foreach ($options as $key => $option) { |
||
92 | $this->setProperty($key, $options); |
||
93 | } |
||
94 | } |
||
95 | |||
96 | |||
97 | /** |
||
98 | * Получить Наименование кнопки |
||
99 | * @return string |
||
100 | */ |
||
101 | public function getName() |
||
102 | { |
||
103 | return $this->name; |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * Установить Наименование кнопки |
||
108 | * @param string $name |
||
109 | * @return $this |
||
110 | */ |
||
111 | public function setName($name) |
||
112 | { |
||
113 | $this->name = $name; |
||
114 | return $this; |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * Получить url кнопки |
||
119 | * @return string |
||
120 | */ |
||
121 | public function getUrl() |
||
122 | { |
||
123 | return $this->url; |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * Установить url кнопки |
||
128 | * @param string $url |
||
129 | * @return $this |
||
130 | */ |
||
131 | public function setUrl($url) |
||
132 | { |
||
133 | $this->url = $url; |
||
134 | return $this; |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * Получить Заголовок кнопки |
||
139 | * @return string |
||
140 | */ |
||
141 | public function getTitle() |
||
142 | { |
||
143 | return $this->title; |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * Установить Заголовок кнопки |
||
148 | * @param string $title |
||
149 | * @return $this |
||
150 | */ |
||
151 | public function setTitle($title) |
||
152 | { |
||
153 | $this->title = $title; |
||
154 | return $this; |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * Получить JS код кнопки |
||
159 | * @return string |
||
160 | */ |
||
161 | public function getJs() |
||
162 | { |
||
163 | return $this->js; |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * Установить JS код кнопки |
||
168 | * @param string $js |
||
169 | * @return $this |
||
170 | */ |
||
171 | public function setJs($js) |
||
0 ignored issues
–
show
|
|||
172 | { |
||
173 | $this->js = $js; |
||
174 | return $this; |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * Получить JS библитеки кнопки |
||
179 | * @return array |
||
180 | */ |
||
181 | public function getLibJs() |
||
182 | { |
||
183 | return $this->libJs; |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * Установить JS библитеки кнопки |
||
188 | * @param array $libJs |
||
189 | * @return $this |
||
190 | */ |
||
191 | public function setLibJs($libJs) |
||
192 | { |
||
193 | $this->libJs = $libJs; |
||
194 | return $this; |
||
195 | } |
||
196 | |||
197 | |||
198 | |||
199 | /** |
||
200 | * Получить Опции кнопки |
||
201 | * @return array|\Traversable |
||
202 | */ |
||
203 | public function getOptions() |
||
204 | { |
||
205 | return $this->options; |
||
206 | } |
||
207 | |||
208 | /** |
||
209 | * Установить Опции кнопки |
||
210 | * @param array|\Traversable $options |
||
211 | * @return $this |
||
212 | */ |
||
213 | public function setOptions($options) |
||
214 | { |
||
215 | $this->options = $options; |
||
0 ignored issues
–
show
It seems like
$options can also be of type object<Traversable> . However, the property $options is declared as type array . 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;
}
![]() |
|||
216 | return $this; |
||
217 | } |
||
218 | |||
219 | /** |
||
220 | * Возвращает атрибут кнопки |
||
221 | * @param $name |
||
222 | * @return mixed|null |
||
223 | */ |
||
224 | public function getAttribute($name) |
||
225 | { |
||
226 | if (isset($this->attributes[$name])) { |
||
227 | return $this->attributes[$name]; |
||
228 | } |
||
229 | return null; |
||
230 | } |
||
231 | |||
232 | /** |
||
233 | * Получить Атрибуты кнопки |
||
234 | * @return array|\Traversable |
||
235 | */ |
||
236 | public function getAttributes() |
||
237 | { |
||
238 | return $this->attributes; |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * Установить Аттрибут кнопки |
||
243 | * @param string $name |
||
244 | * @param mixed $value |
||
245 | * @return $this |
||
246 | */ |
||
247 | public function setAttribute($name, $value) |
||
248 | { |
||
249 | $this->attributes[$name] = $value; |
||
250 | return $this; |
||
251 | } |
||
252 | /** |
||
253 | * Установить Атрибуты кнопки |
||
254 | * @param array|\Traversable $attributes |
||
255 | * @return $this |
||
256 | */ |
||
257 | public function setAttributes($attributes) |
||
258 | { |
||
259 | $this->attributes = $attributes; |
||
0 ignored issues
–
show
It seems like
$attributes can also be of type object<Traversable> . However, the property $attributes is declared as type array . 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;
}
![]() |
|||
260 | return $this; |
||
261 | } |
||
262 | |||
263 | /** |
||
264 | * Получить Значение сортировки |
||
265 | * @return int |
||
266 | */ |
||
267 | public function getOrder() |
||
268 | { |
||
269 | return $this->order; |
||
270 | } |
||
271 | |||
272 | /** |
||
273 | * Установить Значение сортировки |
||
274 | * @param int $order |
||
275 | * @return $this |
||
276 | */ |
||
277 | public function setOrder($order) |
||
278 | { |
||
279 | $this->order = $order; |
||
280 | return $this; |
||
281 | } |
||
282 | } |
||
0 ignored issues
–
show
|
|||
283 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.