ProviderRegistry::getEnvVarName( string $providerId, string $field ): 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 a provider ID and field name to a constant case environment variable name.

Parameters

$providerIdstringrequired
The provider ID.
$fieldstringrequired
The field name.

Return

string The environment variable name in CONSTANT_CASE.

Source

private function getEnvVarName(string $providerId, string $field): string
{
    // Convert camelCase or kebab-case or snake_case to CONSTANT_CASE.
    $constantCaseProviderId = strtoupper((string) preg_replace('/([a-z])([A-Z])/', '$1_$2', str_replace('-', '_', $providerId)));
    $constantCaseField = strtoupper((string) preg_replace('/([a-z])([A-Z])/', '$1_$2', str_replace('-', '_', $field)));
    return "{$constantCaseProviderId}_{$constantCaseField}";
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

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