/
AleksWork
/
diary_plants
Обзор
Документация
Войти
/
AleksWork
/
diary_plants
Код
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/Domain/ValueObject/User/Email.php
39 строк
901 B
AlexeySerov
Move User VolumeObject to directory user
04 мар 2026, 11:12
04 мар 2026, 11:12
0210ecd
Код
Авторство
О чём код?
<?php namespace App\Domain\ValueObject\User; use Webmozart\Assert\Assert as WebmozartAssert; final readonly class Email { private string $value; public function __construct(string $value) { $this->emailValidate($value); $this->value = mb_strtolower($value); } private function emailValidate(?string $email = null): void { if (!is_null($email)) { WebmozartAssert::maxLength($email, 255, 'The email must be a 255 chars length. Got: %s'); WebmozartAssert::email($email, 'The email must be a valid email address. Got: %s'); } } public function toString(): string { return $this->value; } public function isEqual(self $email): bool { return $email->toString() === $this->toString(); } public function __toString(): string { return $this->toString(); } }