active = true; } public function jsonSerialize(): array { return [ "id" => $this->getId(), "active" => $this->active, "apiKey" => $this->apiKey, "validUntil" => $this->validUntil->getTimestamp() ]; } public function getValidUntil(): \DateTime { return $this->validUntil; } public function refresh(SQL $sql, int $days): bool { $this->validUntil = (new \DateTime())->modify("+$days days"); return $this->save($sql, ["valid_until"]); } public function revoke(SQL $sql): bool { $this->active = false; return $this->save($sql, ["active"]); } }