|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* SocialConnect project |
|
4
|
|
|
* @author: Patsura Dmitry @ovr <[email protected]> |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace SocialConnect\Common\Entity; |
|
8
|
|
|
|
|
9
|
|
|
class User extends \stdClass |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @deprecated Use GENDER_MALE instead! |
|
13
|
|
|
*/ |
|
14
|
|
|
const SEX_MALE = 'male_deprecated'; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @deprecated Use GENDER_FEMALE instead! |
|
18
|
|
|
*/ |
|
19
|
|
|
const SEX_FEMALE = 'female_deprecated'; |
|
20
|
|
|
|
|
21
|
|
|
const GENDER_MALE = 'male'; |
|
22
|
|
|
const GENDER_FEMALE = 'female'; |
|
23
|
|
|
const GENDER_OTHER = 'other'; |
|
24
|
|
|
const GENDER_UNKNOWN = 'unknown'; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string |
|
28
|
|
|
*/ |
|
29
|
|
|
public $id; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string |
|
33
|
|
|
*/ |
|
34
|
|
|
public $firstname; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
public $lastname; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
public $email; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var bool |
|
48
|
|
|
*/ |
|
49
|
|
|
public $emailVerified = false; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var \DateTime|null |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $birthday; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var string|null |
|
58
|
|
|
*/ |
|
59
|
|
|
public $username; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* One of the GENDER_-constants |
|
63
|
|
|
* |
|
64
|
|
|
* @var string |
|
65
|
|
|
*/ |
|
66
|
|
|
protected $gender = self::GENDER_UNKNOWN; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @var string|null |
|
70
|
|
|
*/ |
|
71
|
|
|
public $fullname; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @var string|null |
|
75
|
|
|
*/ |
|
76
|
|
|
public $pictureURL; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return \DateTime|null |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getBirthday(): ?\DateTime |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->birthday; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @param \DateTime|null $birthday |
|
88
|
|
|
*/ |
|
89
|
|
|
public function setBirthday(?\DateTime $birthday): void |
|
90
|
|
|
{ |
|
91
|
|
|
$this->birthday = $birthday; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @return string |
|
96
|
|
|
*/ |
|
97
|
2 |
|
public function getGender(): string |
|
98
|
|
|
{ |
|
99
|
2 |
|
return $this->gender; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @param string $sex |
|
104
|
|
|
*/ |
|
105
|
3 |
|
public function setGender(string $gender): void |
|
106
|
|
|
{ |
|
107
|
3 |
|
if ($gender === self::SEX_MALE) { |
|
|
|
|
|
|
108
|
|
|
trigger_error ('the constant SEX_MALE is deprecated. use GENDER_MALE instead', E_USER_DEPRECATED); |
|
109
|
|
|
$gender = self::GENDER_MALE; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
3 |
|
if ($gender === self::SEX_FEMALE) { |
|
|
|
|
|
|
113
|
|
|
trigger_error ('the constant SEX_FEMALE is deprecated. use GENDER_FEMALE instead', E_USER_DEPRECATED); |
|
114
|
|
|
$gender = self::GENDER_FEMALE; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
$genders = [ |
|
118
|
3 |
|
self::GENDER_OTHER, |
|
119
|
3 |
|
self::GENDER_MALE, |
|
120
|
3 |
|
self::GENDER_FEMALE, |
|
121
|
|
|
]; |
|
122
|
3 |
|
if (! in_array($gender, $genders)) { |
|
123
|
|
|
throw new \InvalidArgumentException('Argument $gender is not valid'); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
3 |
|
$this->gender = $gender; |
|
127
|
3 |
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @deprecated use `getGender` instead |
|
131
|
|
|
*/ |
|
132
|
|
|
public function getSex() : string |
|
133
|
|
|
{ |
|
134
|
|
|
trigger_error('getSex is deprecated. Use getGender instead', E_USER_DEPRECATED); |
|
135
|
|
|
return $this->getGender(); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @deprecated Use setGender instead |
|
140
|
|
|
*/ |
|
141
|
|
|
public function setSex(string $sex) : void |
|
142
|
|
|
{ |
|
143
|
|
|
trigger_error('setSex is deprecated. Use setGender instead', E_USER_DEPRECATED); |
|
144
|
|
|
$this->setGender($sex); |
|
145
|
|
|
} |
|
146
|
|
|
} |
|
147
|
|
|
|
This class constant has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.