You are here

public static function StringHelper::camelCase in GraphQL 8.3

Turn a list of machine names into a camel-cased string.

Return value

string A camel-cased concatenation of the input components.

Throws

\InvalidArgumentException If the provided input does can't be converted to a specification compliant string representation for field or type names.

13 calls to StringHelper::camelCase()
DisplayModeIdDeriver::getDerivativeDefinitions in modules/graphql_core/src/Plugin/Deriver/Enums/DisplayModeIdDeriver.php
Gets the definition of all derivatives of a base plugin.
EntityBundleDeriver::getDerivativeDefinitions in modules/graphql_core/src/Plugin/Deriver/Types/EntityBundleDeriver.php
Gets the definition of all derivatives of a base plugin.
EntityFieldDeriver::getDerivativeDefinitionsFromFieldDefinition in modules/graphql_core/src/Plugin/Deriver/Fields/EntityFieldDeriver.php
Provides plugin definition values from fields.
EntityFieldItemDeriver::getDerivativeDefinitionsFromFieldDefinition in modules/graphql_core/src/Plugin/Deriver/Fields/EntityFieldItemDeriver.php
Provides plugin definition values from fields.
EntityFieldPropertyDeriver::getDerivativeDefinitionsFromFieldDefinition in modules/graphql_core/src/Plugin/Deriver/Fields/EntityFieldPropertyDeriver.php
Provides plugin definition values from fields.

... See full list

File

src/Utility/StringHelper.php, line 17

Class

StringHelper

Namespace

Drupal\graphql\Utility

Code

public static function camelCase() {
  $args = func_get_args();
  $components = array_map(function ($component) {
    return preg_replace('/[^a-zA-Z0-9_]/', '_', $component);
  }, $args);
  $components = array_filter(explode('_', implode('_', $components)));
  if (!count($components)) {
    throw new \InvalidArgumentException(sprintf("Failed to create a specification compliant string representation for '%s'.", implode('', $args)));
  }
  $string = implode('', array_map('ucfirst', $components));
  $string = $string && is_numeric($string[0]) ? "_{$string}" : $string;
  return $string;
}