Completed
Push — master ( 1de9b7...830752 )
by Kristof
38:46 queued 24:09
created

FileUploadPagePartAdminType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 40
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A buildForm() 17 17 1
A getBlockPrefix() 4 4 1
A configureOptions() 4 4 1

How to fix   Duplicated Code   

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:

1
<?php
2
3
namespace Kunstmaan\FormBundle\Form;
4
5
use Symfony\Component\Form\AbstractType;
6
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
7
use Symfony\Component\Form\Extension\Core\Type\TextType;
8
use Symfony\Component\Form\FormBuilderInterface;
9
use Symfony\Component\OptionsResolver\OptionsResolver;
10
11
/**
12
 * This class represents the type for the file FileUploadPagePart
13
 */
14 View Code Duplication
class FileUploadPagePartAdminType extends AbstractType
0 ignored issues
show
Duplication introduced by
This class 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...
15
{
16
    /**
17
     * @param FormBuilderInterface $builder The form builder
18
     * @param array                $options The options
19
     */
20
    public function buildForm(FormBuilderInterface $builder, array $options)
21
    {
22
        $builder
23
            ->add('label', TextType::class, array(
24
                'required' => true,
25
                'label' => 'kuma_form.form.file_upload_page_part.label.label',
26
            ))
27
            ->add('required', CheckboxType::class, array(
28
                'required' => false,
29
                'label' => 'kuma_form.form.file_upload_page_part.required.label',
30
            ))
31
            ->add('errormessage_required', TextType::class, array(
32
                'required' => false,
33
                'label' => 'kuma_form.form.file_upload_page_part.errormessage_required.label',
34
            ))
35
        ;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getBlockPrefix()
42
    {
43
        return 'kunstmaan_formbundle_fileuploadpageparttype';
44
    }
45
46
    /**
47
     * @param OptionsResolver $resolver
48
     */
49
    public function configureOptions(OptionsResolver $resolver)
50
    {
51
        $resolver->setDefaults(array('data_class' => 'Kunstmaan\FormBundle\Entity\PageParts\FileUploadPagePart'));
52
    }
53
}
54