|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the G.L.S.R. Apps package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Dev-Int Création <[email protected]>. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Core\Domain\Model; |
|
15
|
|
|
|
|
16
|
|
|
use Administration\Domain\User\Model\VO\UserUuid; |
|
17
|
|
|
use Core\Domain\Common\Model\VO\EmailField; |
|
18
|
|
|
use Core\Domain\Common\Model\VO\NameField; |
|
19
|
|
|
|
|
20
|
|
|
class User |
|
21
|
|
|
{ |
|
22
|
|
|
private UserUuid $uuid; |
|
23
|
|
|
private NameField $username; |
|
24
|
|
|
private EmailField $email; |
|
25
|
|
|
private string $password; |
|
26
|
|
|
private array $roles; |
|
27
|
|
|
|
|
28
|
|
|
public function __construct(UserUuid $uuid, NameField $username, EmailField $email, string $password, array $roles) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->uuid = $uuid; |
|
31
|
|
|
$this->username = $username; |
|
32
|
|
|
$this->email = $email; |
|
33
|
|
|
$this->password = $password; |
|
34
|
|
|
$this->roles = $roles; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public static function create( |
|
38
|
|
|
UserUuid $uuid, |
|
39
|
|
|
NameField $username, |
|
40
|
|
|
EmailField $email, |
|
41
|
|
|
string $password, |
|
42
|
|
|
array $roles = [] |
|
43
|
|
|
): self { |
|
44
|
|
|
return new self($uuid, $username, $email, $password, $roles); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function uuid(): string |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->uuid->toString(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function username(): string |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->username->getValue(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function email(): string |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->email->getValue(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function password(): string |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->password; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function roles(): array |
|
68
|
|
|
{ |
|
69
|
|
|
return \array_unique($this->roles); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function changePassword(string $password): void |
|
73
|
|
|
{ |
|
74
|
|
|
$this->password = $password; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|