| Total Complexity | 6 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | final class Identity implements ContainsRecordedEventsInterface |
||
| 19 | { |
||
| 20 | use EventRecorder; |
||
| 21 | |||
| 22 | private $email; |
||
| 23 | private $password; |
||
| 24 | |||
| 25 | 4 | private function __construct(Email $email, Password $password) |
|
| 26 | { |
||
| 27 | 4 | $this->email = $email; |
|
| 28 | 4 | $this->password = $password; |
|
| 29 | 4 | } |
|
| 30 | |||
| 31 | 4 | public static function create(Email $email, Password $password): self |
|
| 32 | { |
||
| 33 | 4 | $self = new self($email, $password); |
|
| 34 | 4 | $self->record(new IdentityWasCreated($email)); |
|
| 35 | |||
| 36 | 4 | return $self; |
|
| 37 | } |
||
| 38 | |||
| 39 | 1 | public function email(): Email |
|
| 40 | { |
||
| 41 | 1 | return $this->email; |
|
| 42 | } |
||
| 43 | |||
| 44 | 1 | public function changePassword(Password $password): self |
|
| 45 | { |
||
| 46 | 1 | $this->password = $password; |
|
| 47 | 1 | $this->record(new PasswordWasChanged($this->email)); |
|
| 48 | |||
| 49 | 1 | return $this; |
|
| 50 | } |
||
| 51 | |||
| 52 | 2 | public function verify(string $password): bool |
|
| 53 | { |
||
| 54 | 2 | return $this->password->verify($password); |
|
| 55 | } |
||
| 56 | |||
| 57 | 1 | public function delete(): void |
|
| 60 | 1 | } |
|
| 61 | } |
||
| 62 |