You are here

public static function StringHelper::formatPropertyName in GraphQL 8

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

Formats and filters a string as a camel-cased property name.

Strips out any non-alphanumeric characters and turns it into a camel-cased string. This may lead to ambiguous property names. Hence, you need to ensure uniqueness yourself.

Parameters

string $string: The string to be formatted.

Return value

string The formatted string.

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

File

src/Utility/StringHelper.php, line 61

Class

StringHelper
String utilities to help in generting a GraphQL schema.

Namespace

Drupal\graphql\Utility

Code

public static function formatPropertyName($string) {

  // I know words. I have the best words. (© Donald Trump)
  $words = preg_split('/[^a-zA-Z0-9]/', strtolower($string));
  return lcfirst(implode('', array_map('ucfirst', array_map('trim', $words))));
}