get((int) $id); if(!$token) return NULL; else if($token->getSecret() !== $secret) return NULL; else if($token->isRevoked() && !$withRevoked) return NULL; return $token; } function getStaleByUser(int $userId, string $platform, bool $withRevoked = false): ?APIToken { return $this->toEntity($this->table->where([ 'user' => $userId, 'platform' => $platform, 'deleted' => $withRevoked, ])->fetch()); } }