Code Duplication    Length = 29-32 lines in 4 locations

src/Kunstmaan/FormBundle/Form/BooleanFormSubmissionType.php 1 location

@@ 13-44 (lines=32) @@
10
/**
11
 * The type for the BooleanFormSubmissionField
12
 */
13
class BooleanFormSubmissionType extends AbstractType
14
{
15
    /**
16
     * @param FormBuilderInterface $builder The form builder
17
     * @param array                $options The options
18
     */
19
    public function buildForm(FormBuilderInterface $builder, array $options)
20
    {
21
        $keys = array_fill_keys(array('label', 'required', 'constraints'), null);
22
        $fieldOptions = array_filter(array_replace($keys, array_intersect_key($options, $keys)), function ($v) {
23
            return isset($v);
24
        });
25
26
        $builder->add('value', CheckboxType::class, $fieldOptions);
27
    }
28
29
    public function configureOptions(OptionsResolver $resolver)
30
    {
31
        $resolver->setDefaults([
32
            'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\BooleanFormSubmissionField',
33
        ]);
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getBlockPrefix()
40
    {
41
        return 'kunstmaan_formbundle_booleanformsubmissiontype';
42
    }
43
}
44

src/Kunstmaan/FormBundle/Form/EmailFormSubmissionType.php 1 location

@@ 13-42 (lines=30) @@
10
/**
11
 * The type for the EmailFormSubmissionField
12
 */
13
class EmailFormSubmissionType extends AbstractType
14
{
15
    /**
16
     * @param FormBuilderInterface $builder The form builder
17
     * @param array                $options The options
18
     */
19
    public function buildForm(FormBuilderInterface $builder, array $options)
20
    {
21
        $keys = array_fill_keys(array('label', 'required', 'constraints'), null);
22
        $fieldOptions = array_filter(array_replace($keys, array_intersect_key($options, $keys)), function ($v) {
23
            return isset($v);
24
        });
25
        $builder->add('value', EmailType::class, $fieldOptions);
26
    }
27
28
    public function configureOptions(OptionsResolver $resolver)
29
    {
30
        $resolver->setDefaults(array(
31
            'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\EmailFormSubmissionField',
32
        ));
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getBlockPrefix()
39
    {
40
        return 'kunstmaan_formbundle_emailformsubmissiontype';
41
    }
42
}
43

src/Kunstmaan/FormBundle/Form/FileFormSubmissionType.php 1 location

@@ 13-41 (lines=29) @@
10
/**
11
 * This class represents the type for the file FileFormSubmissionField
12
 */
13
class FileFormSubmissionType extends AbstractType
14
{
15
    /**
16
     * @param FormBuilderInterface $builder The form builder
17
     * @param array                $options An array with options
18
     */
19
    public function buildForm(FormBuilderInterface $builder, array $options)
20
    {
21
        $keys = array_fill_keys(array('label', 'required', 'constraints'), null);
22
        $fieldOptions = array_filter(array_replace($keys, array_intersect_key($options, $keys)), function ($v) {
23
            return isset($v);
24
        });
25
26
        $builder->add('file', FileType::class, $fieldOptions);
27
    }
28
29
    public function configureOptions(OptionsResolver $resolver)
30
    {
31
        $resolver->setDefaults(array(
32
            'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\FileFormSubmissionField',
33
        ));
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getBlockPrefix()
40
    {
41
        return 'kunstmaan_formbundle_fileformsubmissiontype';
42
    }
43
}
44

src/Kunstmaan/FormBundle/Form/StringFormSubmissionType.php 1 location

@@ 13-41 (lines=29) @@
10
/**
11
 * The type for the StringFormSubmissionField
12
 */
13
class StringFormSubmissionType extends AbstractType
14
{
15
    /**
16
     * @param FormBuilderInterface $builder The form builder
17
     * @param array                $options The options
18
     */
19
    public function buildForm(FormBuilderInterface $builder, array $options)
20
    {
21
        $keys = array_fill_keys(array('label', 'required', 'constraints'), null);
22
        $fieldOptions = array_filter(array_replace($keys, array_intersect_key($options, $keys)), function ($v) {
23
            return isset($v);
24
        });
25
        $builder->add('value', TextType::class, $fieldOptions);
26
    }
27
28
    public function configureOptions(OptionsResolver $resolver)
29
    {
30
        $resolver->setDefaults(array(
31
            'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\StringFormSubmissionField',
32
        ));
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getBlockPrefix()
39
    {
40
        return 'kunstmaan_formbundle_stringformsubmissiontype';
41
    }
42
}
43