1 | <?php |
||
14 | class Subject |
||
15 | { |
||
16 | private $name; |
||
17 | private $surname; |
||
18 | private $birthDate; |
||
19 | private $gender; |
||
20 | private $belfioreCode; |
||
21 | |||
22 | /** |
||
23 | * Create a Codice Fiscale instance. |
||
24 | * |
||
25 | * @param array $properties An array with all the properties. |
||
26 | * Supported keys are: |
||
27 | * - name: the name; |
||
28 | * - surname: the surname; |
||
29 | * - birthDate: the birth date; |
||
30 | * - gender: the gender; |
||
31 | * - belfioreCode: the Belfiore code. |
||
32 | * @throws Exception |
||
33 | */ |
||
34 | 155 | public function __construct($properties) |
|
35 | { |
||
36 | //Set properties |
||
37 | 155 | if (array_key_exists('name', $properties)) { |
|
38 | 12 | $this->name = $properties['name']; |
|
39 | } |
||
40 | |||
41 | 155 | if (array_key_exists('surname', $properties)) { |
|
42 | 12 | $this->surname = $properties['surname']; |
|
43 | } |
||
44 | |||
45 | 155 | if (array_key_exists('birthDate', $properties)) { |
|
46 | 155 | $this->setBirthDate($properties['birthDate']); |
|
47 | } |
||
48 | |||
49 | 155 | if (array_key_exists('gender', $properties)) { |
|
50 | 155 | $this->gender = $properties['gender']; |
|
51 | } |
||
52 | |||
53 | 155 | if (array_key_exists('belfioreCode', $properties)) { |
|
54 | 155 | $this->belfioreCode = $properties['belfioreCode']; |
|
55 | } |
||
56 | 155 | } |
|
57 | |||
58 | /** |
||
59 | * Get the name. |
||
60 | * |
||
61 | * @return string The name. |
||
62 | */ |
||
63 | 170 | public function getName() |
|
64 | { |
||
65 | 170 | return $this->name; |
|
66 | } |
||
67 | |||
68 | /** |
||
69 | * Set the name. |
||
70 | */ |
||
71 | 1 | public function setName($name) |
|
72 | { |
||
73 | 1 | $this->name = $name; |
|
74 | 1 | } |
|
75 | |||
76 | /** |
||
77 | * Get the name. |
||
78 | * |
||
79 | * @return string The name. |
||
80 | */ |
||
81 | 170 | public function getSurname() |
|
82 | { |
||
83 | 170 | return $this->surname; |
|
84 | } |
||
85 | |||
86 | /** |
||
87 | * Set the surname. |
||
88 | * |
||
89 | * @param string $surname |
||
90 | */ |
||
91 | 1 | public function setSurname($surname) |
|
92 | { |
||
93 | 1 | $this->surname = $surname; |
|
94 | 1 | } |
|
95 | |||
96 | /** |
||
97 | * Get the birthDate. |
||
98 | * |
||
99 | * @return DateTime The birthDate. |
||
100 | */ |
||
101 | 172 | public function getBirthDate() |
|
102 | { |
||
103 | 172 | return $this->birthDate; |
|
104 | } |
||
105 | |||
106 | /** |
||
107 | * Set the birthDate. |
||
108 | * @param mixed $birthDate |
||
109 | * @throws Exception |
||
110 | */ |
||
111 | 155 | public function setBirthDate($birthDate) |
|
112 | { |
||
113 | 155 | if (!$birthDate instanceof DateTimeInterface) { |
|
114 | 12 | $birthDate = new DateTime($birthDate); |
|
115 | } |
||
116 | |||
117 | 155 | $this->birthDate = $birthDate; |
|
118 | 155 | } |
|
119 | |||
120 | /** |
||
121 | * Get the gender. |
||
122 | * |
||
123 | * @return string The gender. |
||
124 | */ |
||
125 | 170 | public function getGender() |
|
129 | |||
130 | /** |
||
131 | * Set the gender. |
||
132 | * |
||
133 | * @param string $gender |
||
134 | */ |
||
135 | 1 | public function setGender($gender) |
|
136 | { |
||
139 | |||
140 | /** |
||
141 | * Get the belfioreCode. |
||
142 | * |
||
143 | * @return string The belfioreCode. |
||
144 | */ |
||
145 | 170 | public function getBelfioreCode() |
|
149 | |||
150 | /** |
||
151 | * Set the belfioreCode. |
||
152 | * @param string $belfioreCode |
||
153 | */ |
||
154 | 1 | public function setBelfioreCode($belfioreCode) |
|
158 | } |
||
159 |