Form   D
last analyzed

Complexity

Total Complexity 61

Size/Duplication

Total Lines 1082
Duplicated Lines 36.32 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 393
loc 1082
c 0
b 0
f 0
wmc 61
lcom 1
cbo 2
rs 4.8266

52 Methods

Rating   Name   Duplication   Size   Complexity  
A label() 0 6 1
A getField() 0 11 2
A hiddenField() 0 6 1
A buttonField() 7 7 1
A radioField() 7 7 1
A textFieldRow() 10 10 1
A getBlock() 0 12 2
A textField() 7 7 1
A fileFieldRow() 10 10 1
A fileField() 7 7 1
A imageFieldRow() 10 10 1
A imageField() 0 8 2
A passwordFieldRow() 10 10 1
A passwordField() 7 7 1
A textAreaFieldRow() 10 10 1
A textAreaField() 7 7 1
A checkboxFieldRow() 10 10 1
A checkBoxField() 7 7 1
A listBoxFieldRow() 10 10 1
A listBoxField() 12 12 2
A dropDownListFieldRow() 10 10 1
A dropDownListField() 11 11 2
A checkBoxListFieldRow() 10 10 1
A checkBoxListField() 0 8 3
A radioButtonListFieldRow() 10 10 1
A radioButtonListField() 0 8 3
A colorFieldRow() 10 10 1
A colorField() 7 7 1
A dateFieldRow() 10 10 1
A dateField() 7 7 1
A dateTimeFieldRow() 10 10 1
A dateTimeField() 7 7 1
A dateTimeLocalFieldRow() 10 10 1
A dateTimeLocalField() 7 7 1
A emailFieldRow() 10 10 1
A emailField() 7 7 1
A numberFieldRow() 10 10 1
A numberField() 7 7 1
A rangeFieldRow() 10 10 1
A rangeField() 7 7 1
A searchFieldRow() 10 10 1
A searchField() 7 7 1
A telFieldRow() 10 10 1
A telField() 7 7 1
A timeFieldRow() 10 10 1
A timeField() 7 7 1
A urlFieldRow() 10 10 1
A urlField() 7 7 1
A monthFieldRow() 10 10 1
A monthField() 7 7 1
A weekFieldRow() 10 10 1
A weekField() 7 7 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like Form often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Form, and based on these observations, apply Extract Interface, too.

1
<?php /** MicroForm */
2
3
namespace Micro\Form;
4
5
use Micro\Web\Html\Html;
6
7
/**
8
 * Form class file.
9
 *
10
 * @author Oleg Lunegov <[email protected]>
11
 * @link https://github.com/linpax/microphp-framework
12
 * @copyright Copyright (c) 2013 Oleg Lunegov
13
 * @license https://github.com/linpax/microphp-framework/blob/master/LICENSE
14
 * @package Micro
15
 * @subpackage Form
16
 * @version 1.0
17
 * @since 1.0
18
 */
19
class Form
20
{
21
    /**
22
     * Render label tag
23
     *
24
     * @access public
25
     *
26
     * @param IFormModel $model model
27
     * @param string $property model property
28
     * @param array $options attributes array
29
     *
30
     * @return string
31
     */
32
    public function label(IFormModel $model, $property, array $options = [])
33
    {
34
        $element = $this->getField($model, $property);
35
36
        return Html::label($model->getLabel($property), $element['id'], $options);
37
    }
38
39
    /**
40
     * Get model field data
41
     *
42
     * @access private
43
     *
44
     * @param IFormModel $model model
45
     * @param string $property model property
46
     *
47
     * @return array
48
     */
49
    protected function getField(IFormModel $model, $property)
50
    {
51
        $cl = get_class($model);
52
        $smallName = substr($cl, strrpos($cl, '\\') + 1);
53
54
        return [
55
            'id' => $smallName.'_'.$property,
56
            'name' => $smallName.'['.$property.']',
57
            'value' => property_exists($model, $property) ? $model->$property : null
58
        ];
59
    }
60
61
    /**
62
     * Render hidden field tag
63
     *
64
     * @access public
65
     *
66
     * @param IFormModel $model model
67
     * @param string $property model property
68
     * @param array $options attributes array
69
     *
70
     * @return string
71
     */
72
    public function hiddenField(IFormModel $model, $property, array $options = [])
73
    {
74
        $element = $this->getField($model, $property);
75
76
        return Html::hiddenField($element['name'], $element['value'], $options);
77
    }
78
79
    /**
80
     * Render button field tag
81
     *
82
     * @access public
83
     *
84
     * @param IFormModel $model model
85
     * @param string $property model property
86
     * @param array $options attributes array
87
     *
88
     * @return string
89
     */
90 View Code Duplication
    public function buttonField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
91
    {
92
        $element = $this->getField($model, $property);
93
        $options['id'] = $element['id'];
94
95
        return Html::buttonField($element['name'], $element['value'], $options);
96
    }
97
98
    /**
99
     * Render radio field tag
100
     *
101
     * @access public
102
     *
103
     * @param IFormModel $model model
104
     * @param string $property model property
105
     * @param array $options attributes array
106
     *
107
     * @return string
108
     */
109 View Code Duplication
    public function radioField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
110
    {
111
        $element = $this->getField($model, $property);
112
        $options['id'] = $element['id'];
113
114
        return Html::radioField($element['name'], $element['value'], $options);
115
    }
116
117
    /**
118
     * Render text field row
119
     *
120
     * @access public
121
     *
122
     * @param IFormModel $model model
123
     * @param string $property model property
124
     * @param array $options attribute array
125
     *
126
     * @return string
127
     */
128 View Code Duplication
    public function textFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
129
    {
130
        $element = $this->getField($model, $property);
131
        $options['id'] = $element['id'];
132
133
        return Html::openTag('div', $this->getBlock('block', $options)).
134
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
135
        $this->textField($model, $property, $options).
136
        Html::closeTag('div');
137
    }
138
139
    // Fields
140
141
    /**
142
     * Get block from options
143
     *
144
     * @access protected
145
     *
146
     * @param string $name Block name
147
     * @param array $options Options array
148
     *
149
     * @return array
150
     */
151
    protected function getBlock($name, array &$options)
152
    {
153
        $block = [];
154
155
        /** @noinspection ReferenceMismatchInspection */
156
        if (array_key_exists($name, $options)) {
157
            $block = $options[$name];
158
            unset($options[$name]);
159
        }
160
161
        return $block;
162
    }
163
164
    /**
165
     * Render text field tag
166
     *
167
     * @access public
168
     *
169
     * @param IFormModel $model model
170
     * @param string $property model property
171
     * @param array $options attributes array
172
     *
173
     * @return string
174
     */
175 View Code Duplication
    public function textField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
176
    {
177
        $element = $this->getField($model, $property);
178
        $options['id'] = $element['id'];
179
180
        return Html::textField($element['name'], $element['value'], $options);
181
    }
182
183
    /**
184
     * Render file field row
185
     *
186
     * @access public
187
     *
188
     * @param IFormModel $model model
189
     * @param string $property model property
190
     * @param array $options attribute array
191
     *
192
     * @return string
193
     */
194 View Code Duplication
    public function fileFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
195
    {
196
        $element = $this->getField($model, $property);
197
        $options['id'] = $element['id'];
198
199
        return Html::openTag('div', $this->getBlock('block', $options)).
200
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
201
        $this->fileField($model, $property, $options).
202
        Html::closeTag('div');
203
    }
204
205
    /**
206
     * Render file field tag
207
     *
208
     * @access public
209
     *
210
     * @param IFormModel $model model
211
     * @param string $property model property
212
     * @param array $options attributes array
213
     *
214
     * @return string
215
     */
216 View Code Duplication
    public function fileField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
217
    {
218
        $element = $this->getField($model, $property);
219
        $options['id'] = $element['id'];
220
221
        return Html::fileField($element['name'], $element['value'], $options);
222
    }
223
224
    /**
225
     * Render image field row
226
     *
227
     * @access public
228
     *
229
     * @param IFormModel $model model
230
     * @param string $property model property
231
     * @param array $options attribute array
232
     *
233
     * @return string
234
     */
235 View Code Duplication
    public function imageFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
236
    {
237
        $element = $this->getField($model, $property);
238
        $options['id'] = $element['id'];
239
240
        return Html::openTag('div', $this->getBlock('block', $options)).
241
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
242
        $this->imageField($model, $property, $options).
243
        Html::closeTag('div');
244
    }
245
246
    /**
247
     * Render image field tag
248
     *
249
     * @access public
250
     *
251
     * @param IFormModel $model model
252
     * @param string $property model property
253
     * @param array $options attributes array
254
     *
255
     * @return string
256
     */
257
    public function imageField(IFormModel $model, $property, array $options = [])
258
    {
259
        $element = $this->getField($model, $property);
260
        $options['id'] = $element['id'];
261
        $image = !empty($options['image']) ? $options['image'] : [];
262
263
        return Html::imageField($element['name'], $element['value'], $image, $options);
264
    }
265
266
    /**
267
     * Render password field row
268
     *
269
     * @access public
270
     *
271
     * @param IFormModel $model model
272
     * @param string $property model property
273
     * @param array $options attribute array
274
     *
275
     * @return string
276
     */
277 View Code Duplication
    public function passwordFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
278
    {
279
        $element = $this->getField($model, $property);
280
        $options['id'] = $element['id'];
281
282
        return Html::openTag('div', $this->getBlock('block', $options)).
283
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
284
        $this->passwordField($model, $property, $options).
285
        Html::closeTag('div');
286
    }
287
288
    /**
289
     * Render password field tag
290
     *
291
     * @access public
292
     *
293
     * @param IFormModel $model model
294
     * @param string $property model property
295
     * @param array $options attributes array
296
     *
297
     * @return string
298
     */
299 View Code Duplication
    public function passwordField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
300
    {
301
        $element = $this->getField($model, $property);
302
        $options['id'] = $element['id'];
303
304
        return Html::passwordField($element['name'], $element['value'], $options);
305
    }
306
307
    /**
308
     * Render textArea field row
309
     *
310
     * @access public
311
     *
312
     * @param IFormModel $model model
313
     * @param string $property model property
314
     * @param array $options attribute array
315
     *
316
     * @return string
317
     */
318 View Code Duplication
    public function textAreaFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
319
    {
320
        $element = $this->getField($model, $property);
321
        $options['id'] = $element['id'];
322
323
        return Html::openTag('div', $this->getBlock('block', $options)).
324
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
325
        $this->textAreaField($model, $property, $options).
326
        Html::closeTag('div');
327
    }
328
329
    /**
330
     * Render textarea tag
331
     *
332
     * @access public
333
     *
334
     * @param IFormModel $model model
335
     * @param string $property model property
336
     * @param array $options attributes array
337
     *
338
     * @return string
339
     */
340 View Code Duplication
    public function textAreaField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
341
    {
342
        $element = $this->getField($model, $property);
343
        $options['id'] = $element['id'];
344
345
        return Html::textArea($element['name'], $element['value'], $options);
346
    }
347
348
    /**
349
     * Render checkbox field row
350
     *
351
     * @access public
352
     *
353
     * @param IFormModel $model model
354
     * @param string $property model property
355
     * @param array $options attribute array
356
     *
357
     * @return string
358
     */
359 View Code Duplication
    public function checkboxFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
360
    {
361
        $element = $this->getField($model, $property);
362
        $options['id'] = $element['id'];
363
364
        return Html::openTag('div', $this->getBlock('block', $options)).
365
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
366
        $this->checkBoxField($model, $property, $options).
367
        Html::closeTag('div');
368
    }
369
370
    /**
371
     * Render check box field tag
372
     *
373
     * @access public
374
     *
375
     * @param IFormModel $model model
376
     * @param string $property model property
377
     * @param array $options attributes array
378
     *
379
     * @return string
380
     */
381 View Code Duplication
    public function checkBoxField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
382
    {
383
        $element = $this->getField($model, $property);
384
        $options['id'] = $element['id'];
385
386
        return Html::checkBoxField($element['name'], $element['value'], $options);
387
    }
388
389
    // Lists
390
391
    /**
392
     * Render listBox field row
393
     *
394
     * @access public
395
     *
396
     * @param IFormModel $model model
397
     * @param string $property model property
398
     * @param array $options attribute array
399
     *
400
     * @return string
401
     */
402 View Code Duplication
    public function listBoxFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
403
    {
404
        $element = $this->getField($model, $property);
405
        $options['id'] = $element['id'];
406
407
        return Html::openTag('div', $this->getBlock('block', $options)).
408
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
409
        $this->listBoxField($model, $property, $options).
410
        Html::closeTag('div');
411
    }
412
413
    /**
414
     * Render list box tag
415
     *
416
     * @access public
417
     *
418
     * @param IFormModel $model model
419
     * @param string $property model property
420
     * @param array $options attributes array
421
     *
422
     * @return string
423
     */
424 View Code Duplication
    public function listBoxField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
425
    {
426
        $element = $this->getField($model, $property);
427
        $options['id'] = $element['id'];
428
        $options['selected'] = $element['value'];
429
430
        if (empty($options['size'])) {
431
            $options['size'] = 3;
432
        }
433
434
        return Html::listBox($element['name'], $this->getBlock('elements', $options), $options);
435
    }
436
437
    /**
438
     * Render text field row
439
     *
440
     * @access public
441
     *
442
     * @param IFormModel $model model
443
     * @param string $property model property
444
     * @param array $options attribute array
445
     *
446
     * @return string
447
     */
448 View Code Duplication
    public function dropDownListFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
449
    {
450
        $element = $this->getField($model, $property);
451
        $options['id'] = $element['id'];
452
453
        return Html::openTag('div', $this->getBlock('block', $options)).
454
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
455
        $this->dropDownListField($model, $property, $options).
456
        Html::closeTag('div');
457
    }
458
459
    /**
460
     * Render drop down list tag
461
     *
462
     * @access public
463
     *
464
     * @param IFormModel $model model
465
     * @param string $property model property
466
     * @param array $options attribute array
467
     *
468
     * @return string
469
     */
470 View Code Duplication
    public function dropDownListField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
471
    {
472
        $element = $this->getField($model, $property);
473
        $options['id'] = $element['id'];
474
475
        if (!empty($element['value'])) {
476
            $options['selected'] = $element['value'];
477
        }
478
479
        return Html::dropDownList($element['name'], $this->getBlock('elements', $options), $options);
480
    }
481
482
    /**
483
     * Render text field row
484
     *
485
     * @access public
486
     *
487
     * @param IFormModel $model model
488
     * @param string $property model property
489
     * @param array $options options array
490
     *
491
     * @return string
492
     */
493 View Code Duplication
    public function checkBoxListFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
494
    {
495
        $element = $this->getField($model, $property);
496
        $options['id'] = $element['id'];
497
498
        return Html::openTag('div', $this->getBlock('block', $options)).
499
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
500
        $this->checkBoxListField($model, $property, $options).
501
        Html::closeTag('div');
502
    }
503
504
    /**
505
     * Render check box list tag
506
     *
507
     * @access public
508
     *
509
     * @param IFormModel $model model
510
     * @param string $property property model
511
     * @param array $options options array
512
     *
513
     * @return string
514
     */
515
    public function checkBoxListField(IFormModel $model, $property, array $options = [])
516
    {
517
        $element = $this->getField($model, $property);
518
        $checkboxes = !empty($options['checkboxes']) ? $options['checkboxes'] : [];
519
        $format = !empty($options['format']) ? $options['format'] : '<p>%check% %text%</p>';
520
521
        return Html::checkBoxList($element['name'], $checkboxes, $format, $element['value']);
522
    }
523
524
    /**
525
     * Render text field row
526
     *
527
     * @access public
528
     *
529
     * @param IFormModel $model model
530
     * @param string $property model property
531
     * @param array $options options array
532
     *
533
     * @return string
534
     */
535 View Code Duplication
    public function radioButtonListFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
536
    {
537
        $element = $this->getField($model, $property);
538
        $options['id'] = $element['id'];
539
540
        return Html::openTag('div', $this->getBlock('block', $options)).
541
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
542
        $this->radioButtonListField($model, $property, $options).
543
        Html::closeTag('div');
544
    }
545
546
    /**
547
     * Render radio button list tag
548
     *
549
     * @access public
550
     *
551
     * @param IFormModel $model model
552
     * @param string $property model property
553
     * @param array $options options array
554
     *
555
     * @return string
556
     */
557
    public function radioButtonListField(IFormModel $model, $property, array $options = [])
558
    {
559
        $element = $this->getField($model, $property);
560
        $radios = !empty($options['radios']) ? $options['radios'] : [];
561
        $format = !empty($options['format']) ? $options['format'] : '<p>%radio% %text%</p>';
562
563
        return Html::radioButtonList($element['name'], $radios, $format, $element['value']);
564
    }
565
566
    // HTML5 Fields
567
568
    /**
569
     * Render color field row
570
     *
571
     * @access public
572
     *
573
     * @param IFormModel $model model
574
     * @param string $property model property
575
     * @param array $options attribute array
576
     *
577
     * @return string
578
     */
579 View Code Duplication
    public function colorFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
580
    {
581
        $element = $this->getField($model, $property);
582
        $options['id'] = $element['id'];
583
584
        return Html::openTag('div', $this->getBlock('block', $options)).
585
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
586
        $this->colorField($model, $property, $options).
587
        Html::closeTag('div');
588
    }
589
590
    /**
591
     * Render color field tag
592
     *
593
     * @access public
594
     *
595
     * @param IFormModel $model model
596
     * @param string $property model property
597
     * @param array $options attributes array
598
     *
599
     * @return string
600
     */
601 View Code Duplication
    public function colorField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
602
    {
603
        $element = $this->getField($model, $property);
604
        $options['id'] = $element['id'];
605
606
        return Html::colorField($element['name'], $element['value'], $options);
607
    }
608
609
    /**
610
     * Render number field row
611
     *
612
     * @access public
613
     *
614
     * @param IFormModel $model model
615
     * @param string $property model property
616
     * @param array $options attribute array
617
     *
618
     * @return string
619
     */
620 View Code Duplication
    public function dateFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
621
    {
622
        $element = $this->getField($model, $property);
623
        $options['id'] = $element['id'];
624
625
        return Html::openTag('div', $this->getBlock('block', $options)).
626
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
627
        $this->dateField($model, $property, $options).
628
        Html::closeTag('div');
629
    }
630
631
    /**
632
     * Render date field tag
633
     *
634
     * @access public
635
     *
636
     * @param IFormModel $model model
637
     * @param string $property model property
638
     * @param array $options attributes array
639
     *
640
     * @return string
641
     */
642 View Code Duplication
    public function dateField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
643
    {
644
        $element = $this->getField($model, $property);
645
        $options['id'] = $element['id'];
646
647
        return Html::dateField($element['name'], $element['value'], $options);
648
    }
649
650
    /**
651
     * Render datetime field row
652
     *
653
     * @access public
654
     *
655
     * @param IFormModel $model model
656
     * @param string $property model property
657
     * @param array $options attribute array
658
     *
659
     * @return string
660
     */
661 View Code Duplication
    public function dateTimeFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
662
    {
663
        $element = $this->getField($model, $property);
664
        $options['id'] = $element['id'];
665
666
        return Html::openTag('div', $this->getBlock('block', $options)).
667
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
668
        $this->dateTimeField($model, $property, $options).
669
        Html::closeTag('div');
670
    }
671
672
    /**
673
     * Render datetime field tag
674
     *
675
     * @access public
676
     *
677
     * @param IFormModel $model model
678
     * @param string $property model property
679
     * @param array $options attributes array
680
     *
681
     * @return string
682
     */
683 View Code Duplication
    public function dateTimeField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
684
    {
685
        $element = $this->getField($model, $property);
686
        $options['id'] = $element['id'];
687
688
        return Html::datetimeField($element['name'], $element['value'], $options);
689
    }
690
691
    /**
692
     * Render datetime-local field row
693
     *
694
     * @access public
695
     *
696
     * @param IFormModel $model model
697
     * @param string $property model property
698
     * @param array $options attribute array
699
     *
700
     * @return string
701
     */
702 View Code Duplication
    public function dateTimeLocalFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
703
    {
704
        $element = $this->getField($model, $property);
705
        $options['id'] = $element['id'];
706
707
        return Html::openTag('div', $this->getBlock('block', $options)).
708
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
709
        $this->dateTimeLocalField($model, $property, $options).
710
        Html::closeTag('div');
711
    }
712
713
    /**
714
     * Render datetime-local field tag
715
     *
716
     * @access public
717
     *
718
     * @param IFormModel $model model
719
     * @param string $property model property
720
     * @param array $options attributes array
721
     *
722
     * @return string
723
     */
724 View Code Duplication
    public function dateTimeLocalField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
725
    {
726
        $element = $this->getField($model, $property);
727
        $options['id'] = $element['id'];
728
729
        return Html::datetimeLocalField($element['name'], $element['value'], $options);
730
    }
731
732
    /**
733
     * Render email field row
734
     *
735
     * @access public
736
     *
737
     * @param IFormModel $model model
738
     * @param string $property model property
739
     * @param array $options attribute array
740
     *
741
     * @return string
742
     */
743 View Code Duplication
    public function emailFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
744
    {
745
        $element = $this->getField($model, $property);
746
        $options['id'] = $element['id'];
747
748
        return Html::openTag('div', $this->getBlock('block', $options)).
749
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
750
        $this->emailField($model, $property, $options).
751
        Html::closeTag('div');
752
    }
753
754
    /**
755
     * Render email field tag
756
     *
757
     * @access public
758
     *
759
     * @param IFormModel $model model
760
     * @param string $property model property
761
     * @param array $options attributes array
762
     *
763
     * @return string
764
     */
765 View Code Duplication
    public function emailField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
766
    {
767
        $element = $this->getField($model, $property);
768
        $options['id'] = $element['id'];
769
770
        return Html::emailField($element['name'], $element['value'], $options);
771
    }
772
773
    /**
774
     * Render number field row
775
     *
776
     * @access public
777
     *
778
     * @param IFormModel $model model
779
     * @param string $property model property
780
     * @param array $options attribute array
781
     *
782
     * @return string
783
     */
784 View Code Duplication
    public function numberFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
785
    {
786
        $element = $this->getField($model, $property);
787
        $options['id'] = $element['id'];
788
789
        return Html::openTag('div', $this->getBlock('block', $options)).
790
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
791
        $this->numberField($model, $property, $options).
792
        Html::closeTag('div');
793
    }
794
795
    /**
796
     * Render number field tag
797
     *
798
     * @access public
799
     *
800
     * @param IFormModel $model model
801
     * @param string $property model property
802
     * @param array $options attributes array
803
     *
804
     * @return string
805
     */
806 View Code Duplication
    public function numberField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
807
    {
808
        $element = $this->getField($model, $property);
809
        $options['id'] = $element['id'];
810
811
        return Html::numberField($element['name'], $element['value'], $options);
812
    }
813
814
    /**
815
     * Render range field row
816
     *
817
     * @access public
818
     *
819
     * @param IFormModel $model model
820
     * @param string $property model property
821
     * @param array $options attribute array
822
     *
823
     * @return string
824
     */
825 View Code Duplication
    public function rangeFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
826
    {
827
        $element = $this->getField($model, $property);
828
        $options['id'] = $element['id'];
829
830
        return Html::openTag('div', $this->getBlock('block', $options)).
831
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
832
        $this->rangeField($model, $property, $options).
833
        Html::closeTag('div');
834
    }
835
836
    /**
837
     * Render range field tag
838
     *
839
     * @access public
840
     *
841
     * @param IFormModel $model model
842
     * @param string $property model property
843
     * @param array $options attributes array
844
     *
845
     * @return string
846
     */
847 View Code Duplication
    public function rangeField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
848
    {
849
        $element = $this->getField($model, $property);
850
        $options['id'] = $element['id'];
851
852
        return Html::rangeField($element['name'], $element['value'], $options);
853
    }
854
855
    /**
856
     * Render search field row
857
     *
858
     * @access public
859
     *
860
     * @param IFormModel $model model
861
     * @param string $property model property
862
     * @param array $options attribute array
863
     *
864
     * @return string
865
     */
866 View Code Duplication
    public function searchFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
867
    {
868
        $element = $this->getField($model, $property);
869
        $options['id'] = $element['id'];
870
871
        return Html::openTag('div', $this->getBlock('block', $options)).
872
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
873
        $this->searchField($model, $property, $options).
874
        Html::closeTag('div');
875
    }
876
877
    /**
878
     * Render search field tag
879
     *
880
     * @access public
881
     *
882
     * @param IFormModel $model model
883
     * @param string $property model property
884
     * @param array $options attributes array
885
     *
886
     * @return string
887
     */
888 View Code Duplication
    public function searchField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
889
    {
890
        $element = $this->getField($model, $property);
891
        $options['id'] = $element['id'];
892
893
        return Html::searchField($element['name'], $element['value'], $options);
894
    }
895
896
    /**
897
     * Render telephone field row
898
     *
899
     * @access public
900
     *
901
     * @param IFormModel $model model
902
     * @param string $property model property
903
     * @param array $options attribute array
904
     *
905
     * @return string
906
     */
907 View Code Duplication
    public function telFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
908
    {
909
        $element = $this->getField($model, $property);
910
        $options['id'] = $element['id'];
911
912
        return Html::openTag('div', $this->getBlock('block', $options)).
913
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
914
        $this->telField($model, $property, $options).
915
        Html::closeTag('div');
916
    }
917
918
    /**
919
     * Render telephone tag
920
     *
921
     * @access public
922
     *
923
     * @param IFormModel $model model
924
     * @param string $property model property
925
     * @param array $options attributes array
926
     *
927
     * @return string
928
     */
929 View Code Duplication
    public function telField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
930
    {
931
        $element = $this->getField($model, $property);
932
        $options['id'] = $element['id'];
933
934
        return Html::telField($element['name'], $element['value'], $options);
935
    }
936
937
    /**
938
     * Render time field row
939
     *
940
     * @access public
941
     *
942
     * @param IFormModel $model model
943
     * @param string $property model property
944
     * @param array $options attribute array
945
     *
946
     * @return string
947
     */
948 View Code Duplication
    public function timeFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
949
    {
950
        $element = $this->getField($model, $property);
951
        $options['id'] = $element['id'];
952
953
        return Html::openTag('div', $this->getBlock('block', $options)).
954
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
955
        $this->timeField($model, $property, $options).
956
        Html::closeTag('div');
957
    }
958
959
    /**
960
     * Render time field tag
961
     *
962
     * @access public
963
     *
964
     * @param IFormModel $model model
965
     * @param string $property model property
966
     * @param array $options attributes array
967
     *
968
     * @return string
969
     */
970 View Code Duplication
    public function timeField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
971
    {
972
        $element = $this->getField($model, $property);
973
        $options['id'] = $element['id'];
974
975
        return Html::timeField($element['name'], $element['value'], $options);
976
    }
977
978
    /**
979
     * Render url field row
980
     *
981
     * @access public
982
     *
983
     * @param IFormModel $model model
984
     * @param string $property model property
985
     * @param array $options attribute array
986
     *
987
     * @return string
988
     */
989 View Code Duplication
    public function urlFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
990
    {
991
        $element = $this->getField($model, $property);
992
        $options['id'] = $element['id'];
993
994
        return Html::openTag('div', $this->getBlock('block', $options)).
995
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
996
        $this->urlField($model, $property, $options).
997
        Html::closeTag('div');
998
    }
999
1000
    /**
1001
     * Render url field tag
1002
     *
1003
     * @access public
1004
     *
1005
     * @param IFormModel $model model
1006
     * @param string $property model property
1007
     * @param array $options attributes array
1008
     *
1009
     * @return string
1010
     */
1011 View Code Duplication
    public function urlField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
1012
    {
1013
        $element = $this->getField($model, $property);
1014
        $options['id'] = $element['id'];
1015
1016
        return Html::urlField($element['name'], $element['value'], $options);
1017
    }
1018
1019
    /**
1020
     * Render month field row
1021
     *
1022
     * @access public
1023
     *
1024
     * @param IFormModel $model model
1025
     * @param string $property model property
1026
     * @param array $options attribute array
1027
     *
1028
     * @return string
1029
     */
1030 View Code Duplication
    public function monthFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
1031
    {
1032
        $element = $this->getField($model, $property);
1033
        $options['id'] = $element['id'];
1034
1035
        return Html::openTag('div', $this->getBlock('block', $options)).
1036
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
1037
        $this->monthField($model, $property, $options).
1038
        Html::closeTag('div');
1039
    }
1040
1041
    /**
1042
     * Render moth field tag
1043
     *
1044
     * @access public
1045
     *
1046
     * @param IFormModel $model model
1047
     * @param string $property model property
1048
     * @param array $options attributes array
1049
     *
1050
     * @return string
1051
     */
1052 View Code Duplication
    public function monthField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
1053
    {
1054
        $element = $this->getField($model, $property);
1055
        $options['id'] = $element['id'];
1056
1057
        return Html::monthField($element['name'], $element['value'], $options);
1058
    }
1059
1060
    /**
1061
     * Render week field row
1062
     *
1063
     * @access public
1064
     *
1065
     * @param IFormModel $model model
1066
     * @param string $property model property
1067
     * @param array $options attribute array
1068
     *
1069
     * @return string
1070
     */
1071 View Code Duplication
    public function weekFieldRow(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
1072
    {
1073
        $element = $this->getField($model, $property);
1074
        $options['id'] = $element['id'];
1075
1076
        return Html::openTag('div', $this->getBlock('block', $options)).
1077
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
1078
        $this->weekField($model, $property, $options).
1079
        Html::closeTag('div');
1080
    }
1081
1082
    /**
1083
     * Render week field tag
1084
     *
1085
     * @access public
1086
     *
1087
     * @param IFormModel $model model
1088
     * @param string $property model property
1089
     * @param array $options attributes array
1090
     *
1091
     * @return string
1092
     */
1093 View Code Duplication
    public function weekField(IFormModel $model, $property, array $options = [])
0 ignored issues
show
Duplication introduced by
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.

Loading history...
1094
    {
1095
        $element = $this->getField($model, $property);
1096
        $options['id'] = $element['id'];
1097
1098
        return Html::weekField($element['name'], $element['value'], $options);
1099
    }
1100
}
1101