Code Duplication    Length = 33-34 lines in 3 locations

src/PlaygroundCore/Service/Formgen.php 3 locations

@@ 219-252 (lines=34) @@
216
                $element = $this->decorate($element, $attr, $inputFilter);
217
                $form->add($element);
218
            }
219
            if (isset($element->line_radio)) {
220
                $attr = $this->getAttributes($element->line_radio[0]);
221
                $element = new Element\Radio($attr['name']);
222
223
                $element->setLabel($attr['label']);
224
                $element->setAttributes(
225
                    array(
226
                        'name'      => $attr['name'],
227
                        'required'  => $attr['required'],
228
                        'allowEmpty'=> !$attr['required'],
229
                        'class'     => $attr['class'],
230
                        'id'        => $attr['id']
231
                    )
232
                );
233
                $values = array();
234
                foreach ($attr['innerData'] as $value) {
235
                    $values[] = $value->label;
236
                }
237
                $element->setValueOptions($values);
238
        
239
                $options = array();
240
                $options['encoding'] = 'UTF-8';
241
                $options['disable_inarray_validator'] = true;
242
        
243
                $element->setOptions($options);
244
        
245
                $form->add($element);
246
        
247
                $inputFilter->add($factory->createInput(array(
248
                    'name'     => $attr['name'],
249
                    'required' => $attr['required'],
250
                    'allowEmpty' => !$attr['required'],
251
                )));
252
            }
253
            if (isset($element->line_checkbox)) {
254
                $attr = $this->getAttributes($element->line_checkbox[0]);
255
                $element = new Element\MultiCheckbox($attr['name']);
@@ 253-286 (lines=34) @@
250
                    'allowEmpty' => !$attr['required'],
251
                )));
252
            }
253
            if (isset($element->line_checkbox)) {
254
                $attr = $this->getAttributes($element->line_checkbox[0]);
255
                $element = new Element\MultiCheckbox($attr['name']);
256
        
257
                $element->setLabel($attr['label']);
258
                $element->setAttributes(
259
                    array(
260
                        'name'      => $attr['name'],
261
                        'required'  => $attr['required'],
262
                        'allowEmpty'=> !$attr['required'],
263
                        'class'     => $attr['class'],
264
                        'id'        => $attr['id']
265
                    )
266
                );
267
268
                $values = array();
269
                foreach ($attr['innerData'] as $value) {
270
                    $values[] = $value->label;
271
                }
272
                $element->setValueOptions($values);
273
                $form->add($element);
274
        
275
                $options = array();
276
                $options['encoding'] = 'UTF-8';
277
                $options['disable_inarray_validator'] = true;
278
        
279
                $element->setOptions($options);
280
        
281
                $inputFilter->add($factory->createInput(array(
282
                    'name'      => $attr['name'],
283
                    'required'  => $attr['required'],
284
                    'allowEmpty'=> !$attr['required'],
285
                )));
286
            }
287
            if (isset($element->line_dropdown)) {
288
                $attr = $this->getAttributes($element->line_dropdown[0]);
289
                $element = new Element\Select($attr['name']);
@@ 287-319 (lines=33) @@
284
                    'allowEmpty'=> !$attr['required'],
285
                )));
286
            }
287
            if (isset($element->line_dropdown)) {
288
                $attr = $this->getAttributes($element->line_dropdown[0]);
289
                $element = new Element\Select($attr['name']);
290
291
                $element->setLabel($attr['label']);
292
                $element->setAttributes(
293
                    array(
294
                        'name'      => $attr['name'],
295
                        'required'  => $attr['required'],
296
                        'allowEmpty'=> !$attr['required'],
297
                        'class'     => $attr['class'],
298
                        'id'        => $attr['id']
299
                    )
300
                );
301
                $values = array();
302
                foreach ($attr['dropdownValues'] as $value) {
303
                    $values[] = $value->dropdown_label;
304
                }
305
                $element->setValueOptions($values);
306
                $form->add($element);
307
        
308
                $options = array();
309
                $options['encoding'] = 'UTF-8';
310
                $options['disable_inarray_validator'] = true;
311
        
312
                $element->setOptions($options);
313
        
314
                $inputFilter->add($factory->createInput(array(
315
                    'name'     => $attr['name'],
316
                    'required' => $attr['required'],
317
                    'allowEmpty' => !$attr['required'],
318
                )));
319
            }
320
            if (isset($element->line_paragraph)) {
321
                $attr = $this->getAttributes($element->line_paragraph[0]);
322
                $element = new Element\Textarea($attr['name']);