refactor: drop unused domain property from email address
This commit is contained in:
parent
e2b69632f6
commit
097ce118dd
1 changed files with 2 additions and 9 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue