SimpleArrayType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A buildForm() 0 4 1
A getParent() 0 6 2
A getName() 0 4 1
1
<?php
2
3
namespace EmanueleMinotto\SimpleArrayBundle\Form\Type;
4
5
use EmanueleMinotto\SimpleArrayBundle\Form\DataTransformer\SimpleArrayTransformer;
6
use Symfony\Component\Form\AbstractType;
7
use Symfony\Component\Form\FormBuilderInterface;
8
9
class SimpleArrayType extends AbstractType
10
{
11
    /**
12
     * Builds the form.
13
     *
14
     * This method is called for each type in the hierarchy starting from the
15
     * top most type. Type extensions can further modify the form.
16
     *
17
     * @param FormBuilderInterface $builder The form builder.
18
     * @param array                $options The options.
19
     *
20
     * @see   FormTypeExtensionInterface::buildForm()
21
     */
22
    public function buildForm(FormBuilderInterface $builder, array $options)
23
    {
24
        $builder->addViewTransformer(new SimpleArrayTransformer());
25
    }
26
27
    /**
28
     * Returns the name of the parent type.
29
     *
30
     * You can also return a type instance from this method, although doing so
31
     * is discouraged because it leads to a performance penalty. The support
32
     * for returning type instances may be dropped from future releases.
33
     *
34
     * @return string
35
     */
36
    public function getParent()
37
    {
38
        return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
39
            ? 'Symfony\Component\Form\Extension\Core\Type\TextType'
40
            : 'text';
41
    }
42
43
    /**
44
     * Returns the name of this type.
45
     *
46
     * @return string
47
     */
48
    public function getName()
49
    {
50
        return 'simple_array';
51
    }
52
}
53