uuid = Uuid::v4()->toRfc4122(); $this->doctor = $doctor; $this->user = $user; $this->nationalCodeHash = hash('sha256', $nationalCode); $this->mobileMasked = self::maskMobile($mobile); $this->verificationMethod = $verificationMethod; $this->createdAt = time(); } public static function maskMobile(string $mobile): string { return strlen($mobile) >= 7 ? substr($mobile, 0, 4) . '***' . substr($mobile, -4) : '***'; } public function markCompleted(): void { $this->status = self::STATUS_COMPLETED; $this->completedAt = time(); } public function markFailed(string $reason): void { $this->status = self::STATUS_FAILED; $this->failureReason = mb_substr($reason, 0, 100); $this->completedAt = time(); } public function getId(): ?int { return $this->id; } public function getUuid(): string { return $this->uuid; } public function getDoctor(): Doctor { return $this->doctor; } public function getUser(): ?User { return $this->user; } public function getStatus(): string { return $this->status; } public function getFailureReason(): ?string { return $this->failureReason; } public function getVerificationMethod(): string { return $this->verificationMethod; } public function getCreatedAt(): int { return $this->createdAt; } public function getCompletedAt(): ?int { return $this->completedAt; } public function toArray(): array { return [ 'uuid' => $this->uuid, 'status' => $this->status, 'doctor' => ['uuid' => $this->doctor->getUuid(), 'name' => $this->doctor->getName()], 'mobile_masked' => $this->mobileMasked, 'verification_method' => $this->verificationMethod, 'failure_reason' => $this->failureReason, 'created_at' => $this->createdAt, 'completed_at' => $this->completedAt, ]; } }