Convert a camelized name to underscored name

@param string $name
@return string
436300
public static function underscore($name)
    {
        if (!isset(self::$underscoreCache[$name])) {
            $underscoreName = strtolower(preg_replace('/(\B)([A-Z])/', '$1_$2', $name));
            self::$underscoreCache[$name] = $underscoreName;

            if (!isset(self::$camelizeCache[$underscoreName])) {
                self::$camelizeCache[$underscoreName] = $name;
            }
        }

        return self::$underscoreCache[$name];
    }
561566
public function getFullName($name)
    {
        $prefix = $this->getPrefix();
        if (strlen($prefix) && false === strpos($name, $prefix)) {
            return $prefix . $name;
        }

        return $name;
    }
918589
public function name($name)
    {
        $prefix = !is_null($this->associatedEntity) && $this->associatedEntity->isSupportedAttribute($name) ?
            $this->keys['POST_WRAP'] . '[' . $this->associatedEntity->getInputName() . ']' :
            $this->keys['POST_WRAP'];

        // Transforms user[name] to data[user][name];
        if (preg_match('/^(.+?)\[(.+)?/', $name, $matches)) {
            return $prefix . '[' . $matches[1].'][' . $matches[2];
        }

        // Transforms user to data[user]
        return $prefix . '[' . $name . ']';
    }
1112942
private static function lowerConstantName(string $name): string
    {
        $parts = explode('\\', $name);

        $lastPart = array_pop($parts);

        $parts = array_map('strtolower', $parts);

        $parts[] = $lastPart;

        return implode('\\', $parts);
    }
239187
private function getRealName(string $name): string
    {
        if (mb_strpos($name, '@ngbm/') !== 0) {
            return $name;
        }

        if (!isset($this->templateMap[$name])) {
            $this->templateMap[$name] = str_replace(
                '@ngbm/',
                '@ngbm_' . $this->configuration->getParameter('design') . '/',
                $name
            );
        }

        return $this->templateMap[$name];
    }
1225002
public function setName(string $name): string
    {
        $this->current->setName($this->prefix . $name);

        return $this->getName();
    }
544664
private function modifyName($name)
    {
        if (!$this->caseSensitive) {
            $name = strtolower($name);
        }
        if ($this->handleDirSep) {
            if (strpos('\\', $name) !== false) {
                $name = str_replace('\\', '/', $name);
            }
        }

        return $name;
    }
990688
public static function normalizeName($name)
    {
        if (false !== ($pos = strrpos($name, '.'))) {
            $name = substr($name, $pos + 1);
        }

        return $name;
    }
1356447
public function getUniqueName($name)
    {
        if (!isset($this->registry[$name])) {
            $this->registry[$name] = 0;

            return $name;
        }

        ++$this->registry[$name];

        return sprintf('%s_%s', $name, $this->registry[$name]);
    }
1321455
public static function coerceName( $name ) {
		$coercedName =
			mb_encode_numericentity( mb_substr( $name, 0, 1, 'UTF-8' ),
				HTMLData::$nameStartCharConvTable, 'UTF-8', true ) .
			mb_encode_numericentity( mb_substr( $name, 1, null, 'UTF-8' ),
				HTMLData::$nameCharConvTable, 'UTF-8', true );
		$coercedName = preg_replace_callback( '/&#x([0-9A-F]*);/',
			function ( $m ) {
				return 'U' . str_pad( $m[1], 6, '0', STR_PAD_LEFT );
			},
			$coercedName );
		return $coercedName;
	}
511489
private function coerceName( $name ) {
		$coercedName = DOMUtils::coerceName( $name );
		if ( $name !== $coercedName ) {
			$this->coerced = true;
		}
		return $coercedName;
	}
516307
private function normalizeHeaderName($name)
    {
        $name = str_replace(array('-', '_'), ' ', (string) $name);
        $name = ucwords(strtolower($name));
        $name = str_replace(' ', '-', $name);
        return $name;
    }
769428
def camel_to_underscore(name):
    
    as_list = []
    length = len(name)
    for index, i in enumerate(name):
        if index != 0 and index != length - 1 and i.isupper():
            as_list.append('_%s' % i.lower())
        else:
            as_list.append(i.lower())

    return ''.join(as_list)
1002082
public function normalizeDefinitionName(string $name): string
    {
        $elements = explode('/', $name);

        return $elements[count($elements) - 1];
    }
787457
protected function shortName($name)
    {
        $name = str_replace('_', ' ', $name);
        $name = ucwords($name);

        return str_replace(' ', '', $name);
    }
1129197
protected function readName($name)
    {
        $name = trim($name);
        $firstName = NULL;
        $lastName = NULL;
        preg_match('/([^,]+),([^,]+)/', $name, $matches);
        if (count($matches) > 0) {
            $lastName = trim($matches[1]);
            $firstName = isset($matches[2]) ? trim($matches[2]) : '';
        } else {
            preg_match_all('/[^\s]+/', $name, $matches);
            if (isset($matches[0])) {
                $matches = $matches[0];
            }
            if (count($matches) > 1) {
                $lastName = array_pop($matches);
                $firstName = implode(' ', $matches);
            }
            if (count($matches) == 1) {
                $firstName = $matches[0];
            }
        }
        return array('firstname' => $firstName, 'lastname' => $lastName);
    }
577017
public static function getDynamicMetadataClassName($name)
    {
        // Convert to a CamelCase class name.
        // See Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter::denormalize()
        $camelCasedName = preg_replace_callback('/(^|_|\.)+(.)/', function ($match) {
            return ('.' === $match[1] ? '_' : '').strtoupper($match[2]);
        }, $name);

        return 'Rokka\Client\Core\DynamicMetadata\\'.$camelCasedName;
    }