/**
 * Replaces placeholders in a template string with values from a replacement items object.
 *
 * The placeholders are in the format %key%, whereby %key% is replaced with the value of the 'key'
 * attribute in the replacementItems object.
 *
 * @param {string} templateString - The template string containing placeholders to be replaced.
 * @param {object} replacementItems - The object containing key-value pairs for replacement.
 * @returns {string} The modified string with all placeholders replaced.
 */
export function interpolateString(templateString: string, replacementItems: { [key: string]: any }): string {
  if (typeof templateString !== 'string') {
    return '';
  }
  return templateString.replace(/%(\w+)%/g, (match, key) => {
    if (replacementItems.hasOwnProperty(key)) {
      return replacementItems[key].toString();
    }
    return match;
  });
}
