Passed
Push — heiglandreas-patch-1 ( 8f4377...c6f183 )
by Andreas
03:53
created

User::setBirthday()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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
    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
88
    {
89 1
        return $this->gender;
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
121
    {
122 1
        $this->setGender($sex);
123 1
    }
124
}
125