id = (int) $this->id; $this->server_id = (int) $this->server_id; $this->user_id = (int) $this->user_id; $this->request_count = (int) $this->request_count; // Keep null distinct from '' — the UI renders one as "Never" and the // other would be an empty cell meaning nothing. $this->last_seen_at = ( null === $this->last_seen_at || '' === $this->last_seen_at ) ? null : (string) $this->last_seen_at; $this->revoked_at = ( null === $this->revoked_at || '' === $this->revoked_at ) ? null : (string) $this->revoked_at; } /** * Whether this client has ever actually called. * * @since 0.4.8 * @return bool */ public function has_been_used(): bool { return null !== $this->last_seen_at; } /** * Whether access was withdrawn. * * @since 0.4.8 * @return bool */ public function is_revoked(): bool { return null !== $this->revoked_at; } /** * Status as the list table shows it. * * Three states rather than two: a client that registered and never called * is not the same as one that is active, and saying so is what tells an * operator "set up wrong" from "not set up yet". * * @since 0.4.8 * @return string One of: revoked, never-used, active. */ public function status(): string { if ( $this->is_revoked() ) { return 'revoked'; } return $this->has_been_used() ? 'active' : 'never-used'; } /** * @since 0.4.8 * @return array */ public function to_array(): array { return get_object_vars( $this ); } }