AbstractEnum::camelCaseToConstant( string $camelCase ): string

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Converts camelCase to CONSTANT_CASE.

Parameters

$camelCasestringrequired
The camelCase string.

Return

string The CONSTANT_CASE version.

Source

private static function camelCaseToConstant(string $camelCase): string
{
    $snakeCase = preg_replace('/([a-z])([A-Z])/', '$1_$2', $camelCase);
    if ($snakeCase === null) {
        return strtoupper($camelCase);
    }
    return strtoupper($snakeCase);
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.