You are here

public static function StringHelper::formatTypeName in GraphQL 8

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

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

Strips out any non-alphanumeric characters and turns it into a camel-cased string.

Parameters

string $string: The string to be formatted.

Return value

string The formatted string.

4 calls to StringHelper::formatTypeName()
ContentEntityTypeResolver::getObjectTypeFromData in src/TypeResolver/ContentEntityTypeResolver.php
Object type resolver callback for entity type schema interfaces.
ContentEntityTypeResolver::resolveFields in src/TypeResolver/ContentEntityTypeResolver.php
Helper function to resolve the list of available fields for a type.
ContentEntityTypeResolver::resolveRecursive in src/TypeResolver/ContentEntityTypeResolver.php
TypedDataTypeResolver::resolveRecursiveComplex in src/TypeResolver/TypedDataTypeResolver.php
Resolves complex data definitions.

File

src/Utility/StringHelper.php, line 21

Class

StringHelper
String utilities to help in generting a GraphQL schema.

Namespace

Drupal\graphql\Utility

Code

public static function formatTypeName($string) {

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