You are here

public static function StringHelper::ensureUnambiguousness in GraphQL 8.2

Same name and namespace in other branches
  1. 8 src/Utility/StringHelper.php \Drupal\graphql\Utility\StringHelper::ensureUnambiguousness()

Ensure that a string is unambiguous given a list of other strings.

Parameters

string $string: The string to ensure unambiguousness for.

array $others: An array of strings that should be taken into consideration.

Return value

string The input string, potentially with a numerical suffix that ensures unambiguousness.

1 call to StringHelper::ensureUnambiguousness()
StringHelper::formatPropertyNameList in src/Utility/StringHelper.php
Formats a list of property names and ensures unambiguousness.

File

src/Utility/StringHelper.php, line 79

Class

StringHelper
String utilities to help in generting a GraphQL schema.

Namespace

Drupal\graphql\Utility

Code

public static function ensureUnambiguousness($string, $others) {
  $suffix = '';
  while (in_array($string . $suffix, $others)) {
    $suffix = (string) (intval($suffix) + 1);
  }
  return $string . $suffix;
}