Completed
Push — master ( d79ecd...9b33ca )
by Davide
12:48
created

Subject   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 63
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
1
<?php
2
3
namespace DavidePastore\CodiceFiscaleRest\Entity;
4
5
use Symfony\Component\Validator\Constraints as Assert;
6
7
class Subject
8
{
9
    public function __construct($data)
10
    {
11
        $this->name = $data['name'];
12
        $this->surname = $data['surname'];
13
        $this->gender = $data['gender'];
14
        $this->birthDate = $data['birthDate'];
15
        $this->belfioreCode = $data['belfioreCode'];
16
        $this->omocodiaLevel = $data['omocodiaLevel'] ?? '';
17
        $this->codiceFiscale = $data['codiceFiscale'] ?? '';
18
    }
19
20
    /**
21
     * @Assert\NotNull(groups={"calculate", "calculateAll", "check"})
22
     */
23
    private $name;
24
    
25
    /**
26
     * @Assert\NotNull(groups={"calculate", "calculateAll", "check"})
27
     */
28
    private $surname;
29
30
31
    /**
32
     * @Assert\Choice(
33
     *      groups={"calculate", "calculateAll", "check"},
34
     *      choices={"M", "F"},
35
     *      message="Choose a valid gender (M or F)."
36
     * )
37
     */
38
    private $gender;
39
40
    /**
41
     * @Assert\Date(groups={"calculate", "calculateAll", "check"})
42
     */
43
    private $birthDate;
44
45
    /**
46
     * @Assert\Sequentially({
47
     *     @Assert\NotBlank(groups={"calculate", "calculateAll", "check"}),
48
     *     @Assert\Length(
49
     *      groups={"calculate", "calculateAll", "check"},
50
     *      min = 4,
51
     *      max = 4
52
     *     )
53
     * })
54
     */
55
    private $belfioreCode;
56
57
    /**
58
     * @Assert\Type(
59
     *      groups={"calculate", "check"},
60
     *      type="numeric"
61
     * )
62
     */
63
    private $omocodiaLevel;
64
65
    /**
66
     * @Assert\NotNull(groups={"check"})
67
     */
68
    private $codiceFiscale;
69
}
70