dont cast email to string, use new value method
This commit is contained in:
parent
099883a13d
commit
a65c9259fa
7 changed files with 12 additions and 7 deletions
|
|
@ -126,7 +126,7 @@ class AuthController
|
|||
$response->getBody()->write(json_encode([
|
||||
'user' => [
|
||||
'id' => $user->getId(),
|
||||
'email' => (string) $user->getEmail(),
|
||||
'email' => $user->getEmail()->value(),
|
||||
'isAdmin' => $user->isAdmin(),
|
||||
],
|
||||
]));
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class JsonUserRepository implements UserRepository
|
|||
|
||||
$users[] = [
|
||||
'id' => $id,
|
||||
'email' => (string) $dto->email,
|
||||
'email' => $dto->email->value(),
|
||||
'passwordHash' => $dto->passwordHash,
|
||||
'isAdmin' => $dto->isAdmin,
|
||||
];
|
||||
|
|
@ -53,7 +53,7 @@ class JsonUserRepository implements UserRepository
|
|||
$users = $this->readUsers();
|
||||
|
||||
foreach ($users as $data) {
|
||||
if ($data['email'] === (string) $email) {
|
||||
if ($data['email'] === $email->value()) {
|
||||
return $this->hydrate($data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ class EmailAddress
|
|||
$this->normalized = $email;
|
||||
}
|
||||
|
||||
public function value(): string
|
||||
{
|
||||
return $this->normalized;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->normalized;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue