refactor: drop unused domain property from email address

This commit is contained in:
Yisroel Baum 2026-05-17 10:11:33 +03:00
parent e2b69632f6
commit 097ce118dd
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -8,8 +8,6 @@ final readonly class EmailAddress
{
private string $normalized;
private string $domain;
private const ERROR_MESSAGE = 'Invalid email address:';
public function __construct(string $email)
@ -22,8 +20,8 @@ final readonly class EmailAddress
}
[$local, $domain] = explode('@', $trimmed, 2);
$this->domain = mb_strtolower($domain);
$normalized = $local . '@' . $this->domain;
$domain = mb_strtolower($domain);
$normalized = $local . '@' . $domain;
if (filter_var($normalized, FILTER_VALIDATE_EMAIL) === false) {
throw new InvalidArgumentException(self::ERROR_MESSAGE . " $email");
@ -42,11 +40,6 @@ final readonly class EmailAddress
return $this->normalized === $other->normalized;
}
public function getDomain(): string
{
return $this->domain;
}
public function __toString(): string
{
return $this->normalized;