LeadType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 7
dl 0
loc 57
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildForm() 0 53 2
1
<?php
2
3
namespace Starkerxp\LeadBundle\Form\Type;
4
5
use Starkerxp\LeadBundle\Constraints\LeadExist;
6
use Starkerxp\LeadBundle\Constraints\LeadNotExist;
7
use Starkerxp\StructureBundle\Form\Type\AbstractType;
8
use Symfony\Component\Form\Extension\Core\Type;
9
use Symfony\Component\Form\FormBuilderInterface;
10
use Symfony\Component\Validator\Constraints;
11
12
class LeadType extends AbstractType
13
{
14
    public function buildForm(FormBuilderInterface $builder, array $options)
15
    {
16
        $builder
17
            ->add(
18
                'origin',
19
                Type\TextType::class,
20
                [
21
                    'constraints' => [
22
                        new Constraints\NotBlank(),
23
                        new Constraints\Length(['min' => 3]),
24
                    ],
25
                ]
26
            )
27
            ->add(
28
                'external_reference',
29
                Type\TextType::class,
30
                [
31
                    'constraints' => [
32
                        new Constraints\NotBlank(),
33
                        new Constraints\Length(['min' => 1]),
34
                        $options['method'] === "PUT" ? new LeadNotExist() : new LeadExist(),
35
                    ],
36
                ]
37
            )
38
            ->add(
39
                'product',
40
                Type\TextType::class,
41
                [
42
                    'constraints' => [
43
                        new Constraints\NotBlank(),
44
                        new Constraints\Length(['min' => 3]),
45
                    ],
46
                ]
47
            )
48
            ->add(
49
                'date_event',
50
                Type\DateTimeType::class,
51
                [
52
                    'widget' => 'single_text',
53
                    'format' => 'yyyy-MM-dd HH:mm:ss',
54
                ]
55
            )
56
            ->add(
57
                'ip_address',
58
                Type\TextType::class,
59
                [
60
                    "constraints" => [
61
                        new Constraints\Ip(),
62
                    ],
63
                ]
64
            )
65
            ->add('pixel', Type\TextType::class);
66
    }
67
68
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
69