Create User Zone

This commit is contained in:
omair saleh
2022-09-25 03:46:14 +08:00
parent 8143e2b9a2
commit b008ad5106
59 changed files with 1757 additions and 12 deletions
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace Src\Zone\User\Domain\Model\ValueObjects;
use Src\Common\Domain\Exceptions\IncorrectEmailFormatException;
use Src\Common\Domain\Exceptions\RequiredException;
final class Email implements \JsonSerializable
{
private string $email;
public function __construct(?string $email, $isOptional = false)
{
if (!$email && !$isOptional) {
throw new RequiredException('email');
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new IncorrectEmailFormatException();
}
$this->email = $email;
}
public function __toString(): string
{
return $this->email;
}
public function jsonSerialize(): string
{
return $this->email;
}
}