TranslationType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 46
rs 10
c 0
b 0
f 0
ccs 14
cts 22
cp 0.6364

3 Methods

Rating   Name   Duplication   Size   Complexity  
A buildForm() 0 19 2
A setDefaultOptions() 0 8 1
A getName() 0 4 1
1
<?php
2
/*
3
 * This file is part of the TranslationLoaderBundle package.
4
 *
5
 * (c) Marc Aschmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Asm\TranslationLoaderBundle\Form\Type;
12
13
use Symfony\Component\Form\AbstractType;
14
use Symfony\Component\Form\FormBuilderInterface;
15
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
16
17
class TranslationType extends AbstractType
18
{
19
    /**
20
     * @param FormBuilderInterface $builder
21
     * @param array $options
22
     */
23 1
    public function buildForm(FormBuilderInterface $builder, array $options)
24
    {
25 1
        if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) {
26 1
            $textTypeName = 'Symfony\Component\Form\Extension\Core\Type\TextType';
27 1
            $textareaTypeName = 'Symfony\Component\Form\Extension\Core\Type\TextareaType';
28 1
            $submitTypeName = 'Symfony\Component\Form\Extension\Core\Type\SubmitType';
29 1
        } else {
30
            $textTypeName = 'text';
31
            $textareaTypeName = 'textarea';
32
            $submitTypeName = 'submit';
33
        }
34
35
        $builder
36 1
            ->add('transLocale', $textTypeName, array('required' => true))
37 1
            ->add('messageDomain', $textTypeName, array('required' => true))
38 1
            ->add('transKey', $textTypeName, array('required' => true))
39 1
            ->add('translation', $textareaTypeName)
40 1
            ->add('save', $submitTypeName);
41 1
    }
42
43
    /**
44
     * @param OptionsResolverInterface $resolver
45
     */
46
    public function setDefaultOptions(OptionsResolverInterface $resolver)
47
    {
48
        $resolver->setDefaults(
49
            array(
50
                'data_class' => 'Asm\TranslationLoaderBundle\Entity\Translation',
51
            )
52
        );
53
    }
54
55
    /**
56
     * @return string
57
     */
58 1
    public function getName()
59
    {
60 1
        return 'asm_translation';
61
    }
62
}
63