get($this->getRecord()->user); } function getSecret(): string { return $this->getRecord()->secret; } function getFormattedToken(): string { return $this->getId() . "-" . chunk_split($this->getSecret(), 8, "-") . "jill"; } function getPlatform(): ?string { return $this->getRecord()->platform; } function isRevoked(): bool { return $this->isDeleted(); } function setUser(User $user): void { $this->stateChanges("user", $user->getId()); } function setSecret(string $secret): void { throw new ISE("Setting secret manually is prohbited"); } function revoke(): void { $this->delete(); } function save(): void { if(is_null($this->getRecord())) $this->stateChanges("secret", bin2hex(openssl_random_pseudo_bytes(36))); parent::save(); } }