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 Roman Malashin <[email protected]> |
||
5 | */ |
||
6 | |||
7 | namespace Nnx\DataGrid\Column; |
||
8 | |||
9 | use Nnx\DataGrid\Column\Header\HeaderInterface; |
||
10 | use Nnx\DataGrid\Mutator\MutatorInterface; |
||
11 | use Traversable; |
||
12 | |||
13 | abstract class AbstractColumn implements ColumnInterface |
||
14 | { |
||
15 | /** |
||
16 | * Заголовок колонки |
||
17 | * @var HeaderInterface |
||
18 | */ |
||
19 | protected $header; |
||
20 | |||
21 | /** |
||
22 | * Шаблон колонки |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $template; |
||
26 | |||
27 | /** |
||
28 | * Наименование колонки. По данному полю осуществляется маппинг данных из БД при отображении |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $name; |
||
32 | |||
33 | /** |
||
34 | * Опции колонки |
||
35 | * @var array | Traversable |
||
36 | */ |
||
37 | protected $options = []; |
||
38 | |||
39 | /** |
||
40 | * Атрибуты колонки необходимые для отображения |
||
41 | * @var array | Traversable |
||
42 | */ |
||
43 | protected $attributes = []; |
||
44 | |||
45 | /** |
||
46 | * По данному полю осуществляется сортировка колонок при выводе |
||
47 | * @var int |
||
48 | */ |
||
49 | protected $order; |
||
50 | |||
51 | /** |
||
52 | * Флаг сортировки данных |
||
53 | * @var bool |
||
54 | */ |
||
55 | protected $sortable; |
||
56 | |||
57 | /** |
||
58 | * Массив мутаторов данных для данной колонки |
||
59 | * @var array|Traversable |
||
60 | */ |
||
61 | protected $mutators = []; |
||
62 | |||
63 | /** |
||
64 | * Предустановленные для данной колонки мутаторы |
||
65 | * @var array|Traversable |
||
66 | */ |
||
67 | protected $invokableMutators; |
||
68 | |||
69 | /** |
||
70 | * Устанавливает свойства класса |
||
71 | * @param string $key |
||
72 | * @param array $options |
||
73 | */ |
||
74 | View Code Duplication | protected function setProperty($key, &$options) |
|
0 ignored issues
–
show
|
|||
75 | { |
||
76 | if (array_key_exists($key, $options)) { |
||
77 | $setter = 'set' . ucfirst($key); |
||
78 | if (method_exists($this, $setter)) { |
||
79 | $this->$setter($options[$key]); |
||
80 | unset($options[$key]); |
||
81 | } |
||
82 | } |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Конструктор класса |
||
87 | * @param array $options |
||
88 | */ |
||
89 | public function __construct(array $options = []) |
||
90 | { |
||
91 | foreach ($options as $key => $option) { |
||
92 | $this->setProperty($key, $options); |
||
93 | } |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Устанавливает заголовок для колонки |
||
98 | * @param HeaderInterface | array | Traversable $header |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function setHeader($header) |
||
102 | { |
||
103 | $this->header = $header; |
||
104 | return $this; |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Возвращает объект заголовка для колонки |
||
109 | * @return HeaderInterface |
||
110 | */ |
||
111 | public function getHeader() |
||
112 | { |
||
113 | return $this->header; |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Устанавливает путь до шаблона строки |
||
118 | * @param string $template |
||
119 | * @return $this |
||
120 | */ |
||
121 | public function setTemplate($template) |
||
122 | { |
||
123 | $this->template = $template; |
||
124 | return $this; |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * Возвраащет путь до шаблона |
||
129 | * @return string |
||
130 | */ |
||
131 | public function getTemplate() |
||
132 | { |
||
133 | return $this->template; |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * Имя колонки |
||
138 | * @param string $name |
||
139 | * @return $this |
||
140 | */ |
||
141 | public function setName($name) |
||
142 | { |
||
143 | $this->name = strtolower($name); |
||
144 | return $this; |
||
145 | } |
||
146 | |||
147 | /** |
||
148 | * Возвращает индекс по которому будут выбираться для колонки данные предоставленные адаптером |
||
149 | * @return string |
||
150 | */ |
||
151 | public function getName() |
||
152 | { |
||
153 | return $this->name; |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * Опции и настройки колонки |
||
158 | * @param array $options |
||
159 | * @return $this |
||
160 | */ |
||
161 | public function setOptions(array $options = []) |
||
162 | { |
||
163 | $this->options = $options; |
||
164 | return $this; |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * Возвращает опции колонки |
||
169 | * @return array |
||
170 | */ |
||
171 | public function getOptions() |
||
172 | { |
||
173 | return $this->options; |
||
174 | } |
||
175 | |||
176 | /** |
||
177 | * Аттрибут колонки |
||
178 | * @param string $name |
||
179 | * @param mixed $value |
||
180 | * @return $this |
||
181 | */ |
||
182 | public function setAttribute($name, $value) |
||
183 | { |
||
184 | $this->attributes[$name] = $value; |
||
185 | return $this; |
||
186 | } |
||
187 | |||
188 | /** |
||
189 | * Аттрибуты колонки |
||
190 | * @param array $attributes |
||
191 | * @return $this |
||
192 | */ |
||
193 | public function setAttributes(array $attributes = []) |
||
194 | { |
||
195 | $this->attributes = $attributes; |
||
196 | return $this; |
||
197 | } |
||
198 | |||
199 | /** |
||
200 | * Возвращает атрибут колонки |
||
201 | * @param $name |
||
202 | * @return mixed|null |
||
203 | */ |
||
204 | public function getAttribute($name) |
||
205 | { |
||
206 | if (isset($this->attributes[$name])) { |
||
207 | return $this->attributes[$name]; |
||
208 | } |
||
209 | return null; |
||
210 | } |
||
211 | |||
212 | |||
213 | /** |
||
214 | * Возвращает атрибуты колонки |
||
215 | * @return array |
||
216 | */ |
||
217 | public function getAttributes() |
||
218 | { |
||
219 | return $this->attributes; |
||
220 | } |
||
221 | |||
222 | /** |
||
223 | * Возвращает параметр по которому сортируются колонки |
||
224 | * @return int |
||
225 | */ |
||
226 | public function getOrder() |
||
227 | { |
||
228 | return $this->order; |
||
229 | } |
||
230 | |||
231 | /** |
||
232 | * Устанавливает параметр для сортировки колонок |
||
233 | * @param int $order |
||
234 | * @return $this |
||
235 | */ |
||
236 | public function setOrder($order) |
||
237 | { |
||
238 | $this->order = $order; |
||
239 | return $this; |
||
240 | } |
||
241 | |||
242 | /** |
||
243 | * Флаг сообщающий можно ли сортировать по колонке |
||
244 | * @return bool |
||
245 | */ |
||
246 | public function getSortable() |
||
247 | { |
||
248 | return $this->sortable; |
||
249 | } |
||
250 | |||
251 | /** |
||
252 | * Устанавливает флаг информирующий можно сортировать или нет по колонке |
||
253 | * @param bool $sortable |
||
254 | * @return $this |
||
255 | */ |
||
256 | public function setSortable($sortable) |
||
257 | { |
||
258 | $this->sortable = $sortable; |
||
259 | return $this; |
||
260 | } |
||
261 | |||
262 | /** |
||
263 | * @return array|Traversable |
||
264 | */ |
||
265 | public function getMutators() |
||
266 | { |
||
267 | return $this->mutators; |
||
268 | } |
||
269 | |||
270 | /** |
||
271 | * Устанавливает мутаторы для колонки |
||
272 | * @param array|Traversable $mutators |
||
273 | * @return $this |
||
274 | */ |
||
275 | public function setMutators($mutators) |
||
276 | { |
||
277 | $this->mutators = $mutators; |
||
278 | return $this; |
||
279 | } |
||
280 | |||
281 | /** |
||
282 | * Добавляет мутьатор для ячеек данных |
||
283 | * @param MutatorInterface $mutator |
||
284 | * @return mixed |
||
285 | */ |
||
286 | public function addMutator(MutatorInterface $mutator) |
||
287 | { |
||
288 | $this->mutators[] = $mutator; |
||
289 | return $this; |
||
290 | } |
||
291 | |||
292 | /** |
||
293 | * Возвращает предустановленные мутаторы |
||
294 | * @return array|Traversable |
||
295 | */ |
||
296 | public function getInvokableMutators() |
||
297 | { |
||
298 | return $this->invokableMutators; |
||
299 | } |
||
300 | |||
301 | /** |
||
302 | * Устанавливает мутаторы по умолчнию |
||
303 | * @param array|Traversable $invokableMutators |
||
304 | * @return $this |
||
305 | */ |
||
306 | public function setInvokableMutators($invokableMutators) |
||
307 | { |
||
308 | $this->invokableMutators = $invokableMutators; |
||
309 | return $this; |
||
310 | } |
||
311 | } |
||
0 ignored issues
–
show
|
|||
312 |
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.