user_helper = $user_helper; } /** * Get the token for a user. * * @param int $user_id The user ID. * * @return string The token data. * * @throws RuntimeException If the token is not found or invalid. */ public function get_token( int $user_id ): string { $refresh_jwt = $this->user_helper->get_meta( $user_id, self::META_KEY, true ); if ( ! \is_string( $refresh_jwt ) || $refresh_jwt === '' ) { throw new RuntimeException( 'Unable to retrieve the refresh token.' ); } return $refresh_jwt; } /** * Store the token for a user. * * @param int $user_id The user ID. * @param string $value The token value. * * @return void */ public function store_token( int $user_id, string $value ): void { $this->user_helper->update_meta( $user_id, self::META_KEY, $value, ); } /** * Delete the token for a user. * * @param int $user_id The user ID. * * @return void */ public function delete_token( int $user_id ): void { $this->user_helper->delete_meta( $user_id, self::META_KEY ); } }