replaceCaseWith method

String replaceCaseWith(
  1. String oldValue,
  2. String newValue
)

Implementation

String replaceCaseWith(String oldValue, String newValue) {
  String fileContents = replaceAll(
    oldValue.toCamelCase,
    newValue.toCamelCase,
  );

  fileContents = fileContents.replaceAll(
    oldValue.toSmallCaseText,
    newValue.toSmallCaseText,
  );

  fileContents = fileContents.replaceAll(
    oldValue.toTitleCase,
    newValue.toTitleCase,
  );

  fileContents = fileContents.replaceAll(
    oldValue.toPascalCase,
    newValue.toPascalCase,
  );

  fileContents = fileContents.replaceAll(
    oldValue.toUpperCase(),
    newValue.toUpperCase(),
  );

  fileContents = fileContents.replaceAll(
    oldValue.toKebabCase,
    newValue.toKebabCase,
  );

  fileContents = fileContents.replaceAll(
    oldValue.toSnakeCase,
    newValue.toSnakeCase,
  );

  fileContents = fileContents.replaceAll(
    oldValue.toLowerCase(),
    newValue.toLowerCase(),
  );

  return fileContents;
}