= $maxAttempts ) { return false; } set_transient( $key, $current + 1, $windowMinutes * 60 ); return true; } /** * Get the number of remaining attempts. * * @param string $type The type of limit. * @param string $identifier The identifier. * @param int $maxAttempts Maximum number of attempts allowed. * * @return int The remaining attempts. */ public function getRemainingAttempts( string $type, string $identifier, int $maxAttempts ): int { $key = 'doi_rate_' . $type . '_' . md5( $identifier ); $current = (int) get_transient( $key ); return max( 0, $maxAttempts - $current ); } }