User::setSex()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3.1406

Importance

Changes 0
Metric Value
cc 3
eloc 3
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 3
cts 4
cp 0.75
crap 3.1406
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 SEX_MALE = 'male';
12
    const SEX_FEMALE = 'female';
13
14
    /**
15
     * @var string
16
     */
17
    public $id;
18
19
    /**
20
     * @var string
21
     */
22
    public $firstname;
23
24
    /**
25
     * @var string
26
     */
27
    public $lastname;
28
29
    /**
30
     * @var string
31
     */
32
    public $email;
33
34
    /**
35
     * @var bool
36
     */
37
    public $emailVerified = false;
38
39
    /**
40
     * @var \DateTime|null
41
     */
42
    protected $birthday;
43
44
    /**
45
     * @var string|null
46
     */
47
    public $username;
48
49
    /**
50
     * Should be female or male
51
     *
52
     * @var string|null
53
     */
54
    protected $sex;
55
56
    /**
57
     * @var string|null
58
     */
59
    public $fullname;
60
61
    /**
62
     * @var string|null
63
     */
64
    public $pictureURL;
65
66
    /**
67
     * @return \DateTime|null
68
     */
69 1
    public function getBirthday(): ?\DateTime
70
    {
71 1
        return $this->birthday;
72
    }
73
74
    /**
75
     * @param \DateTime|null $birthday
76
     */
77 2
    public function setBirthday(?\DateTime $birthday): void
78
    {
79 2
        $this->birthday = $birthday;
80
    }
81
82
    /**
83
     * @return string|null
84
     */
85 2
    public function getSex(): ?string
86
    {
87 2
        return $this->sex;
88
    }
89
90
    /**
91
     * @param string $sex
92
     */
93 3
    public function setSex(string $sex): void
94
    {
95 3
        if ($sex !== self::SEX_MALE && $sex !== self::SEX_FEMALE) {
96
            throw new \InvalidArgumentException('Argument $sex is not valid');
97
        }
98
99 3
        $this->sex = $sex;
100
    }
101
}
102