DefinitionType   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 6
Bugs 1 Features 1
Metric Value
wmc 3
c 6
b 1
f 1
lcom 0
cbo 4
dl 0
loc 46
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B buildForm() 0 31 1
A setDefaultOptions() 0 6 1
A getName() 0 4 1
1
<?php
2
3
namespace Padam87\AttributeBundle\Form;
4
5
use Symfony\Component\Form\AbstractType;
6
use Symfony\Component\Form\FormBuilderInterface;
7
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
8
9
class DefinitionType extends AbstractType
10
{
11
    public function buildForm(FormBuilderInterface $builder, array $options)
12
    {
13
        $builder->add('name', 'text', [
14
        ]);
15
        $builder->add('description', 'textarea', [
16
            'required' => false,
17
        ]);
18
        $builder->add('type', 'choice', [
19
            'choices' => [
20
                'text'      => 'Text',
21
                'textarea'  => 'Textarea',
22
                'choice'    => 'Select',
23
                'checkbox'  => 'Checkbox',
24
                'radio'     => 'Radio',
25
            ],
26
        ]);
27
        $builder->add('options', 'collection', [
28
            'type'          => new OptionType(),
29
            'allow_add'     => true,
30
            'allow_delete'  => true,
31
            'prototype'     => true,
32
            'by_reference'  => false,
33
            'options'       => [],
34
        ]);
35
        $builder->add('unit', 'text', [
36
            'required' => false,
37
        ]);
38
        $builder->add('required', 'checkbox', [
39
            'required' => false,
40
        ]);
41
    }
42
43
    public function setDefaultOptions(OptionsResolverInterface $resolver)
44
    {
45
        $resolver->setDefaults([
46
            'data_class' => 'Padam87\AttributeBundle\Entity\Definition',
47
        ]);
48
    }
49
50
    public function getName()
51
    {
52
        return 'definition';
53
    }
54
}
55