19 lines
416 B
PHP
19 lines
416 B
PHP
<?php
|
|
|
|
namespace MMT\DDDSharedKernel\ValueObjects;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
final class Email extends ValueObject
|
|
{
|
|
public function __construct(
|
|
public private(set) string $email
|
|
)
|
|
{
|
|
$this->email = trim(mb_strtolower($email));
|
|
|
|
if (!filter_var($this->email, FILTER_VALIDATE_EMAIL)) {
|
|
throw new InvalidArgumentException("Invalid email format");
|
|
}
|
|
}
|
|
} |