Completed
Push — master ( 6d6774...64f3ed )
by Jeroen
11:23 queued 05:13
created

LocaleWhiteListAdminType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 42
loc 42
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A buildForm() 10 10 1
A getBlockPrefix() 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\LeadGenerationBundle\Form\Rule;
4
5
use Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface;
6
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
7
use Symfony\Component\Form\FormBuilderInterface;
8
9 View Code Duplication
class LocaleWhiteListAdminType extends AbstractRuleAdminType
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...
10
{
11
    private $locales;
12
13
    public function __construct(DomainConfigurationInterface $domainConfiguration)
14
    {
15
        $locales = $domainConfiguration->getFrontendLocales();
16
        $this->locales = array_combine($locales, $locales);
17
    }
18
19
    /**
20
     * Builds the form.
21
     *
22
     * This method is called for each type in the hierarchy starting form the
23
     * top most type. Type extensions can further modify the form.
24
     *
25
     * @see FormTypeExtensionInterface::buildForm()
26
     *
27
     * @param FormBuilderInterface $builder The form builder
28
     * @param array                $options The options
29
     */
30
    public function buildForm(FormBuilderInterface $builder, array $options)
31
    {
32
        $builder->add('locale', ChoiceType::class, array(
33
            'label' => 'kuma_lead_generation.form.locale_white_list.locale.label',
34
            'attr' => array(
35
                'info_text' => 'kuma_lead_generation.form.locale_white_list.locale.info_text',
36
            ),
37
            'choices' => $this->locales,
38
        ));
39
    }
40
41
    /**
42
     * Returns the name of this type.
43
     *
44
     * @return string The name of this type
45
     */
46
    public function getBlockPrefix()
47
    {
48
        return 'locale_whitelist_form';
49
    }
50
}
51