$dto->email->value(), 'password_hash' => $dto->passwordHash, 'is_admin' => $dto->isAdmin, ]); return $this->toDomain($model); } public function find(int $id): ?User { $model = UserModel::find($id); return $model === null ? null : $this->toDomain($model); } public function findByEmail(EmailAddress $email): ?User { $model = UserModel::where('email', $email->value())->first(); return $model === null ? null : $this->toDomain($model); } private function toDomain(UserModel $model): User { return new User( id: $model->id, email: new EmailAddress($model->email), passwordHash: $model->password_hash, isAdmin: $model->is_admin, ); } }