1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- /**
- * Created by PhpStorm.
- * user: JZ
- * Date: 2019/7/13
- * Time: 12:02
- */
- class User implements JsonSerializable {
- private $name; // 姓名
- private $contact; // 联系方式
- private $contactType; // 联系类型:MOBILE(手机号),EMAIL(邮箱),EMPLOYEEID(员工ID),NUMBER(员工编号)
- public function jsonSerialize() {
- $data = [];
- foreach ($this as $key=>$val){
- if ($val !== null) $data[$key] = $val;
- }
- if(sizeof($data) < 1){
- return null;
- }
- return $data;
- }
- /**
- * @return mixed
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * @param mixed $name
- */
- public function setName($name)
- {
- $this->name = $name;
- }
- /**
- * @return mixed
- */
- public function getContact()
- {
- return $this->contact;
- }
- /**
- * @param mixed $contact
- */
- public function setContact($contact)
- {
- $this->contact = $contact;
- }
- /**
- * @return mixed
- */
- public function getContactType()
- {
- return $this->contactType;
- }
- /**
- * @param mixed $contactType
- */
- public function setContactType($contactType)
- {
- $this->contactType = $contactType;
- }
- }
|