1 <?php
2 /* --------------------------------------------------------------
3 Customer.inc.php 2015-02-18 gm
4 Gambio GmbH
5 http://www.gambio.de
6 Copyright (c) 2014 Gambio GmbH
7 Released under the GNU General Public License (Version 2)
8 [http://www.gnu.org/licenses/gpl-2.0.html]
9 --------------------------------------------------------------
10 */
11
12 MainFactory::load_class('CustomerInterface');
13
14 /**
15 * Class Customer
16 *
17 * This class is used for managing customer data
18 *
19 * @category System
20 * @package Customer
21 * @implements CustomerInterface
22 */
23 class Customer implements CustomerInterface
24 {
25 /**
26 * Customer ID.
27 * @var int
28 */
29 protected $id;
30
31 /**
32 * Customer number.
33 * @var CustomerNumberInterface
34 */
35 protected $customerNumber;
36
37 /**
38 * Customer gender.
39 * @var CustomerGenderInterface
40 */
41 protected $gender;
42
43 /**
44 * Customer first name.
45 * @var CustomerFirstnameInterface
46 */
47 protected $firstname;
48
49 /**
50 * Customer last name.
51 * @var CustomerLastnameInterface
52 */
53 protected $lastname;
54
55 /**
56 * Customer date of birth.
57 * @var DateTime
58 */
59 protected $dateOfBirth;
60
61 /**
62 * Customer VAT number.
63 * @var CustomerVatNumberInterface
64 */
65 protected $vatNumber;
66
67 /**
68 * Customer VAT number status.
69 * @var int
70 */
71 protected $vatNumberStatus = 0;
72
73 /**
74 * Customer call number.
75 * @var CustomerCallNumberInterface
76 */
77 protected $telephoneNumber;
78
79 /**
80 * Customer fax number.
81 * @var CustomerCallNumberInterface
82 */
83 protected $faxNumber;
84
85 /**
86 * Customer E-Mail address.
87 * @var CustomerEmailInterface
88 */
89 protected $email;
90
91 /**
92 * Customer password.
93 * @var CustomerPasswordInterface
94 */
95 protected $password;
96
97 /**
98 * Customer default address.
99 * @var CustomerAddressInterface
100 */
101 protected $defaultAddress;
102
103 /**
104 * Customer status ID.
105 * @var int
106 */
107 protected $customerStatusId = 0;
108
109 /**
110 * Customer guest status.
111 * @var bool
112 */
113 protected $isGuest = false;
114
115
116 /**
117 * Constructor of the class Customer
118 */
119 public function __construct()
120 {
121 $this->customerNumber = MainFactory::create('CustomerNumber', '');
122 $this->gender = MainFactory::create('CustomerGender', '');
123 $this->firstname = MainFactory::create('CustomerFirstname', '');
124 $this->lastname = MainFactory::create('CustomerLastname', '');
125 $this->dateOfBirth = MainFactory::create('CustomerDateOfBirth', '0000-01-01 00:00:00');
126 $this->vatNumber = MainFactory::create('CustomerVatNumber', '');
127 $this->telephoneNumber = MainFactory::create('CustomerCallNumber', '');
128 $this->faxNumber = MainFactory::create('CustomerCallNumber', '');
129 $this->email = MainFactory::create('CustomerEmail', 'temp@example.org');
130 $this->password = MainFactory::create('CustomerPassword', md5(time() . rand(1, 999000)));
131 }
132
133
134 /**
135 * Returns the customer's ID.
136 *
137 * @return int Customer's ID.
138 */
139 public function getId()
140 {
141 return $this->id;
142 }
143
144
145 /**
146 * Returns the customer's number.
147 *
148 * @return string customerNumber Customer's number.
149 */
150 public function getCustomerNumber()
151 {
152 return $this->customerNumber;
153 }
154
155
156 /**
157 * Sets the customer's number.
158 *
159 * @param CustomerNumberInterface $customerNumber Customer's number.
160 */
161 public function setCustomerNumber(CustomerNumberInterface $customerNumber)
162 {
163 $this->customerNumber = $customerNumber;
164 }
165
166
167 /**
168 * Returns the customer's status ID.
169 *
170 * @return int customerStatusId Customer's status ID.
171 */
172 public function getStatusId()
173 {
174 return $this->customerStatusId;
175 }
176
177
178 /**
179 * Sets the customer's status ID.
180 *
181 * @param int $p_statusId Customer's status ID.
182 *
183 * @throws InvalidArgumentException
184 */
185 public function setStatusId($p_statusId)
186 {
187 if(!is_numeric($p_statusId) || ((int)$p_statusId != (double)$p_statusId))
188 {
189 throw new InvalidArgumentException('$p_statusId int expected.');
190 }
191
192 $this->customerStatusId = (int)$p_statusId;
193 }
194
195
196 /**
197 * Checks if customer is a guest.
198 *
199 * @return bool Is customer a guest?
200 */
201 public function isGuest()
202 {
203 return $this->isGuest;
204 }
205
206
207 /**
208 * Returns the customer's gender.
209 *
210 * @return CustomerGenderInterface Customer's gender.
211 */
212 public function getGender()
213 {
214 return $this->gender;
215 }
216
217
218 /**
219 * Returns the customer's first name.
220 *
221 * @return CustomerFirstnameInterface Customer's first name.
222 */
223 public function getFirstname()
224 {
225 return $this->firstname;
226 }
227
228
229 /**
230 * Returns the customer's last name.
231 *
232 * @return CustomerLastnameInterface Customer's last name.
233 */
234 public function getLastname()
235 {
236 return $this->lastname;
237 }
238
239
240 /**
241 * Returns the customer's date of birth.
242 *
243 * @return DateTime date of birth Customer's date of birth.
244 */
245 public function getDateOfBirth()
246 {
247 return $this->dateOfBirth;
248 }
249
250
251 /**
252 * Returns the customer's VAT number.
253 *
254 * @return CustomerVatNumberInterface Customer's VAT number.
255 */
256 public function getVatNumber()
257 {
258 return $this->vatNumber;
259 }
260
261
262 /**
263 * Returns the customer's VAT number status.
264 *
265 * @return int Customer's VAT number status.
266 */
267 public function getVatNumberStatus()
268 {
269 return $this->vatNumberStatus;
270 }
271
272
273 /**
274 * Returns the customer's telephone number.
275 *
276 * @return CustomerCallNumberInterface Customer's telephone number.
277 */
278 public function getTelephoneNumber()
279 {
280 return $this->telephoneNumber;
281 }
282
283
284 /**
285 * Returns the customer's fax number.
286 *
287 * @return CustomerCallNumberInterface Customer's fax number.
288 */
289 public function getFaxNumber()
290 {
291 return $this->faxNumber;
292 }
293
294
295 /**
296 * Returns the customer's email.
297 *
298 * @return CustomerEmailInterface Customer's email.
299 */
300 public function getEmail()
301 {
302 return $this->email;
303 }
304
305
306 /**
307 * Returns the customer's password.
308 *
309 * @return CustomerPasswordInterface Customer's password.
310 */
311 public function getPassword()
312 {
313 return $this->password;
314 }
315
316
317 /**
318 * Returns the customer's default address.
319 *
320 * @return CustomerAddressInterface Customer's default address.
321 */
322 public function getDefaultAddress()
323 {
324 return $this->defaultAddress;
325 }
326
327
328 /**
329 * Sets the customer's guest status.
330 *
331 * @param boolean $p_isPGuest Customer's guest status.
332 *
333 * @throws InvalidArgumentException if $p_isGuest is not a boolean value
334 */
335 public function setGuest($p_isPGuest)
336 {
337 if(!is_bool($p_isPGuest))
338 {
339 throw new InvalidArgumentException('$p_isGuest bool expected.');
340 }
341 $this->isGuest = (boolean)$p_isPGuest;
342 }
343
344
345 /**
346 * Sets the customer's ID.
347 *
348 * @param IdType $id customerId Customer ID.
349 *
350 * @throws InvalidArgumentException If $p_id is not an integer or if $p_id is lower than 1.
351 */
352 public function setId(IdType $id)
353 {
354 $this->id = (int)(string)$id;
355 }
356
357
358 /**
359 * Sets the customer's gender.
360 *
361 * @param CustomerGenderInterface $gender Customer's gender.
362 */
363 public function setGender(CustomerGenderInterface $gender)
364 {
365 $this->gender = $gender;
366 }
367
368
369 /**
370 * Sets the customer's first name.
371 *
372 * @param CustomerFirstnameInterface $firstname Customer's first name.
373 */
374 public function setFirstname(CustomerFirstnameInterface $firstname)
375 {
376 $this->firstname = $firstname;
377 }
378
379
380 /**
381 * Sets the customer's last name.
382 *
383 * @param CustomerLastnameInterface $lastname Customer's last name.
384 */
385 public function setLastname(CustomerLastnameInterface $lastname)
386 {
387 $this->lastname = $lastname;
388 }
389
390
391 /**
392 * Sets the customer's date of birth.
393 *
394 * @param DateTime $dateOfBirth date of birth Customer's date of birth.
395 */
396 public function setDateOfBirth(DateTime $dateOfBirth)
397 {
398 $this->dateOfBirth = $dateOfBirth;
399 }
400
401
402 /**
403 * Sets the customer's VAT number.
404 *
405 * @param CustomerVatNumberInterface $vatNumber Customer's VAT number.
406 */
407 public function setVatNumber(CustomerVatNumberInterface $vatNumber)
408 {
409 $this->vatNumber = $vatNumber;
410 }
411
412
413 /**
414 * Sets the customer's VAT number status.
415 *
416 * @param int $p_vatNumberStatus Customer's VAT number status.
417 */
418 public function setVatNumberStatus($p_vatNumberStatus)
419 {
420 $this->vatNumberStatus = (int)$p_vatNumberStatus;
421 }
422
423
424 /**
425 * Sets the customer's telephone number.
426 *
427 * @param CustomerCallNumberInterface $telephoneNumber Customer's telephone number.
428 */
429 public function setTelephoneNumber(CustomerCallNumberInterface $telephoneNumber)
430 {
431 $this->telephoneNumber = $telephoneNumber;
432 }
433
434
435 /**
436 * Sets the customer's fax number.
437 *
438 * @param CustomerCallNumberInterface $faxNumber Customer's fax number.
439 */
440 public function setFaxNumber(CustomerCallNumberInterface $faxNumber)
441 {
442 $this->faxNumber = $faxNumber;
443 }
444
445
446 /**
447 * Sets the customer's email.
448 *
449 * @param CustomerEmailInterface $email Customer's email.
450 */
451 public function setEmail(CustomerEmailInterface $email)
452 {
453 $this->email = $email;
454 }
455
456
457 /**
458 * Sets the customer's password.
459 *
460 * @param CustomerPasswordInterface $password Customer's password.
461 */
462 public function setPassword(CustomerPasswordInterface $password)
463 {
464 $this->password = $password;
465 }
466
467
468 /**
469 * Sets the customer's default address.
470 *
471 * @param CustomerAddressInterface $address Customer's default address.
472 */
473 public function setDefaultAddress(CustomerAddressInterface $address)
474 {
475 $this->defaultAddress = $address;
476 }
477 }