Completed
Push — feature/VSVGVQ-20 ( 845985...6d1142 )
by Luc
04:12
created

User::withPassword()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace VSV\GVQ_API\User\Models;
4
5
use Ramsey\Uuid\UuidInterface;
6
use VSV\GVQ_API\Common\ValueObjects\NotEmptyString;
7
use VSV\GVQ_API\User\ValueObjects\Email;
8
use VSV\GVQ_API\User\ValueObjects\Password;
9
use VSV\GVQ_API\User\ValueObjects\Role;
10
11
class User
12
{
13
    /**
14
     * @var UuidInterface
15
     */
16
    private $id;
17
18
    /**
19
     * @var Email
20
     */
21
    private $email;
22
23
    /**
24
     * @var NotEmptyString
25
     */
26
    private $lastName;
27
28
    /**
29
     * @var NotEmptyString
30
     */
31
    private $firstName;
32
33
    /**
34
     * @var Role
35
     */
36
    private $role;
37
38
    /**
39
     * @var Password|null
40
     */
41
    private $password;
42
43
    /**
44
     * @param UuidInterface $id
45
     * @param Email $email
46
     * @param NotEmptyString $lastName
47
     * @param NotEmptyString $firstName
48
     * @param Role $role
49
     */
50
    public function __construct(
51
        UuidInterface $id,
52
        Email $email,
53
        NotEmptyString $lastName,
54
        NotEmptyString $firstName,
55
        Role $role
56
    ) {
57
        $this->id = $id;
58
        $this->email = $email;
59
        $this->lastName = $lastName;
60
        $this->firstName = $firstName;
61
        $this->role = $role;
62
    }
63
64
    /**
65
     * @return UuidInterface
66
     */
67
    public function getId(): UuidInterface
68
    {
69
        return $this->id;
70
    }
71
72
    /**
73
     * @return Email
74
     */
75
    public function getEmail(): Email
76
    {
77
        return $this->email;
78
    }
79
80
    /**
81
     * @return NotEmptyString
82
     */
83
    public function getLastName(): NotEmptyString
84
    {
85
        return $this->lastName;
86
    }
87
88
    /**
89
     * @return NotEmptyString
90
     */
91
    public function getFirstName(): NotEmptyString
92
    {
93
        return $this->firstName;
94
    }
95
96
    /**
97
     * @return Role
98
     */
99
    public function getRole(): Role
100
    {
101
        return $this->role;
102
    }
103
104
    /**
105
     * @param Password $password
106
     * @return User
107
     */
108
    public function withPassword(Password $password): User
109
    {
110
        $c = clone $this;
111
        $c->password = $password;
112
        return $c;
113
    }
114
115
    /**
116
     * @return Password|null
117
     */
118
    public function getPassword(): ?Password
119
    {
120
        return $this->password;
121
    }
122
}
123