You are here

public static function Container::underscore in Service Container 7

Same name in this branch
  1. 7 src/DependencyInjection/Container.php \Drupal\service_container\DependencyInjection\Container::underscore()
  2. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Container.php \Symfony\Component\DependencyInjection\Container::underscore()
Same name and namespace in other branches
  1. 7.2 src/DependencyInjection/Container.php \Drupal\service_container\DependencyInjection\Container::underscore()

Un-camelizes a string.

Parameters

$name: The string to underscore.

Return value

string The underscored string.

File

src/DependencyInjection/Container.php, line 86
Contains \Drupal\service_container\DependencyInjection\Container

Class

Container
Container is a DI container that provides services to users of the class.

Namespace

Drupal\service_container\DependencyInjection

Code

public static function underscore($name) {
  return strtolower(preg_replace(array(
    '/([A-Z]+)([A-Z][a-z])/',
    '/([a-z\\d])([A-Z])/',
  ), array(
    '\\1_\\2',
    '\\1_\\2',
  ), $name));
}