id = (int) $this->id; // F032 — B18 defensive cast. Post-migration invariant: server_id is NEVER NULL. $this->server_id = (int) $this->server_id; $this->user_id = (int) $this->user_id; // B18: $wpdb returns tinyint as string. Cast at boundary. $this->revoked = (int) $this->revoked; } /** * @return array */ public function to_array(): array { return array( 'id' => $this->id, 'token_hash' => $this->token_hash, 'token_type' => $this->token_type, 'client_id' => $this->client_id, 'server_id' => $this->server_id, 'user_id' => $this->user_id, 'scope' => $this->scope, 'resource' => $this->resource, 'expires_at' => $this->expires_at, 'revoked' => $this->revoked, 'token_family_id' => $this->token_family_id, 'created_at' => $this->created_at, ); } /** * True if the token is non-revoked AND not expired. * * @param string $now Current GMT time in mysql format. * @return bool */ public function is_active( string $now ): bool { return 0 === $this->revoked && $this->expires_at > $now; } }