ServerType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B buildForm() 0 24 1
A configureOptions() 0 7 1
1
<?php
2
3
namespace Xdaysaysay\AdminBundle\Form\Type;
4
5
use Symfony\Component\Form\AbstractType;
6
use Symfony\Component\Form\FormBuilderInterface;
7
use Symfony\Component\OptionsResolver\OptionsResolver;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
/**
11
 * Class ServerType
12
 * @package Xdaysaysay\AdminBundle\Form\Type
13
 */
14
class ServerType extends AbstractType
15
{
16
    /**
17
     * @param FormBuilderInterface $builder
18
     * @param array $options
19
     *
20
     * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException
21
     * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException
22
     * @throws \Symfony\Component\Validator\Exception\MissingOptionsException
23
     */
24
    public function buildForm(FormBuilderInterface $builder, array $options)
25
    {
26
        $builder->add('name', null, [
27
            'label'       => 'admin.server.form.label.name',
28
            'constraints' => [
29
                new Assert\NotBlank(),
30
            ],
31
        ]);
32
        $builder->add('host', null, [
33
            'label'       => 'admin.server.form.label.host',
34
            'constraints' => [
35
                new Assert\NotBlank(),
36
            ],
37
        ]);
38
        $builder->add('ssl', null, [
39
            'label' => 'admin.server.form.label.ssl',
40
        ]);
41
        $builder->add('http_port', null, [
42
            'label'       => 'admin.server.form.label.http_port',
43
            'constraints' => [
44
                new Assert\NotBlank(),
45
            ],
46
        ]);
47
    }
48
49
    /**
50
     * @param OptionsResolver $resolver
51
     *
52
     * @throws \Symfony\Component\OptionsResolver\Exception\AccessException
53
     */
54
    public function configureOptions(OptionsResolver $resolver)
55
    {
56
        $resolver->setDefaults([
57
            'data_class'         => 'Xdaysaysay\CoreBundle\Entity\Server',
58
            'translation_domain' => 'admin',
59
        ]);
60
    }
61
}
62