User.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * user: JZ
  5. * Date: 2019/7/13
  6. * Time: 12:02
  7. */
  8. class User implements JsonSerializable {
  9. private $name; // 姓名
  10. private $contact; // 联系方式
  11. private $contactType; // 联系类型:MOBILE(手机号),EMAIL(邮箱),EMPLOYEEID(员工ID),NUMBER(员工编号)
  12. public function jsonSerialize() {
  13. $data = [];
  14. foreach ($this as $key=>$val){
  15. if ($val !== null) $data[$key] = $val;
  16. }
  17. if(sizeof($data) < 1){
  18. return null;
  19. }
  20. return $data;
  21. }
  22. /**
  23. * @return mixed
  24. */
  25. public function getName()
  26. {
  27. return $this->name;
  28. }
  29. /**
  30. * @param mixed $name
  31. */
  32. public function setName($name)
  33. {
  34. $this->name = $name;
  35. }
  36. /**
  37. * @return mixed
  38. */
  39. public function getContact()
  40. {
  41. return $this->contact;
  42. }
  43. /**
  44. * @param mixed $contact
  45. */
  46. public function setContact($contact)
  47. {
  48. $this->contact = $contact;
  49. }
  50. /**
  51. * @return mixed
  52. */
  53. public function getContactType()
  54. {
  55. return $this->contactType;
  56. }
  57. /**
  58. * @param mixed $contactType
  59. */
  60. public function setContactType($contactType)
  61. {
  62. $this->contactType = $contactType;
  63. }
  64. }