email = mb_strtolower(trim($email)); $this->mailjetListId = $mailjetListId; $this->setNames($firstName, $lastName); $this->createdAt = new \DateTimeImmutable(); $this->updatedAt = $this->createdAt; } public function getId(): ?int { return $this->id; } public function getEmail(): string { return $this->email; } public function getMailjetListId(): int { return $this->mailjetListId; } public function getConfirmedAt(): ?\DateTimeImmutable { return $this->confirmedAt; } public function getRevokedAt(): ?\DateTimeImmutable { return $this->revokedAt; } public function getFirstName(): ?string { return $this->firstName; } public function getLastName(): ?string { return $this->lastName; } public function isConfirmed(): bool { return null !== $this->confirmedAt && null === $this->revokedAt; } public function isRevoked(): bool { return null !== $this->revokedAt; } public function markConfirmed(?\DateTimeImmutable $now = null, ?string $firstName = null, ?string $lastName = null): void { $timestamp = $now ?? new \DateTimeImmutable(); $this->confirmedAt = $timestamp; $this->revokedAt = null; $this->mergeNames($firstName, $lastName); $this->updatedAt = $timestamp; } public function markRevoked(?\DateTimeImmutable $now = null): void { $timestamp = $now ?? new \DateTimeImmutable(); $this->revokedAt = $timestamp; $this->updatedAt = $timestamp; } public function setNames(?string $firstName, ?string $lastName): void { $this->firstName = self::normalizeName($firstName); $this->lastName = self::normalizeName($lastName); } public function mergeNames(?string $firstName, ?string $lastName): void { if (null !== $firstName) { $this->firstName = self::normalizeName($firstName); } if (null !== $lastName) { $this->lastName = self::normalizeName($lastName); } } private static function normalizeName(?string $value): ?string { if (null === $value) { return null; } $trimmed = trim($value); if ('' === $trimmed) { return null; } return mb_substr($trimmed, 0, self::NAME_MAX_LENGTH); } }