Total Complexity | 7 |
Total Lines | 114 |
Duplicated Lines | 0 % |
Coverage | 68.42% |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class User extends \stdClass |
||
10 | { |
||
11 | const GENDER_MALE = 'male'; |
||
12 | const GENDER_FEMALE = 'female'; |
||
13 | const GENDER_OTHER = 'other'; |
||
14 | const GENDER_UNKNOWN = 'unknown'; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | public $id; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | public $firstname; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | public $lastname; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | public $email; |
||
35 | |||
36 | /** |
||
37 | * @var bool |
||
38 | */ |
||
39 | public $emailVerified = false; |
||
40 | |||
41 | /** |
||
42 | * @var \DateTime|null |
||
43 | */ |
||
44 | protected $birthday; |
||
45 | |||
46 | /** |
||
47 | * @var string|null |
||
48 | */ |
||
49 | public $username; |
||
50 | |||
51 | /** |
||
52 | * One of the GENDER_-constants |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $gender = self::GENDER_UNKNOWN; |
||
57 | |||
58 | /** |
||
59 | * @var string|null |
||
60 | */ |
||
61 | public $fullname; |
||
62 | |||
63 | /** |
||
64 | * @var string|null |
||
65 | */ |
||
66 | public $pictureURL; |
||
67 | |||
68 | /** |
||
69 | * @return \DateTime|null |
||
70 | */ |
||
71 | public function getBirthday(): ?\DateTime |
||
72 | { |
||
73 | return $this->birthday; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param \DateTime|null $birthday |
||
78 | */ |
||
79 | public function setBirthday(?\DateTime $birthday): void |
||
80 | { |
||
81 | $this->birthday = $birthday; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @return string |
||
86 | */ |
||
87 | 1 | public function getGender(): string |
|
90 | } |
||
91 | |||
92 | /** |
||
93 | * @param string $sex |
||
94 | */ |
||
95 | 1 | public function setGender(string $gender): void |
|
96 | { |
||
97 | $genders = [ |
||
98 | 1 | self::GENDER_OTHER, |
|
99 | 1 | self::GENDER_MALE, |
|
100 | 1 | self::GENDER_FEMALE, |
|
101 | ]; |
||
102 | 1 | if (! in_array($gender, $genders)) { |
|
103 | throw new \InvalidArgumentException('Argument $gender is not valid'); |
||
104 | } |
||
105 | |||
106 | 1 | $this->gender = $gender; |
|
107 | 1 | } |
|
108 | |||
109 | /** |
||
110 | * @deprecated use `getGender` instead |
||
111 | */ |
||
112 | 1 | public function getSex() : string |
|
113 | { |
||
114 | 1 | return $this->getGender(); |
|
115 | } |
||
116 | |||
117 | /** |
||
118 | * @deprecated Use setGender instead |
||
119 | */ |
||
120 | 1 | public function setSex(string $sex) : void |
|
123 | 1 | } |
|
124 | } |
||
125 |