userId = (string)$result->getInteger(0); $this->remoteAddr = $result->getString(1); $this->created = $result->getInteger(2); $this->code = $result->isNull(3) ? null : $result->getString(3); } public function getUserId(): string { return $this->userId; } public function getRemoteAddressRaw(): string { return $this->remoteAddr; } public function getRemoteAddress(): IPAddress { return IPAddress::parse($this->remoteAddr); } public function getCreatedTime(): int { return $this->created; } public function getCreatedAt(): DateTime { return DateTime::fromUnixTimeSeconds($this->created); } public function getExpiresTime(): int { return $this->created + self::LIFETIME; } public function getExpiresAt(): DateTime { return DateTime::fromUnixTimeSeconds($this->created + self::LIFETIME); } public function hasExpired(): bool { return $this->getExpiresTime() <= time(); } public function hasCode(): bool { return $this->code !== null; } public function getCode(): ?string { return $this->code; } public function isValid(): bool { return $this->hasCode() && !$this->hasExpired(); } }