Completed
Push — master ( 9a7beb...fe7356 )
by Jeroen
13:51
created

BooleanFormSubmissionType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 29.03 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 9
loc 31
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A buildForm() 9 9 1
A configureOptions() 0 6 1
A getBlockPrefix() 0 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\FormBuilderInterface;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
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 1 View Code Duplication
    public function buildForm(FormBuilderInterface $builder, 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...
20
    {
21 1
        $keys = array_fill_keys(array('label', 'required', 'constraints'), null);
22
        $fieldOptions = array_filter(array_replace($keys, array_intersect_key($options, $keys)), function ($v) {
23 1
            return isset($v);
24 1
        });
25
26 1
        $builder->add('value', CheckboxType::class, $fieldOptions);
27 1
    }
28
29 1
    public function configureOptions(OptionsResolver $resolver)
30
    {
31 1
        $resolver->setDefaults([
32 1
            'data_class' => 'Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\BooleanFormSubmissionField',
33
        ]);
34 1
    }
35
36
    /**
37
     * @return string
38
     */
39 1
    public function getBlockPrefix()
40
    {
41 1
        return 'kunstmaan_formbundle_booleanformsubmissiontype';
42
    }
43
}
44