Oihana PHP

dotKebab.php

Table of Contents

Functions

dotKebab()  : string
Converts a camelCase or PascalCase string into a format where the first word is separated by a dot (.) from the rest, which are joined using kebab-case (-).

Functions

dotKebab()

Converts a camelCase or PascalCase string into a format where the first word is separated by a dot (.) from the rest, which are joined using kebab-case (-).

dotKebab(string|null $source) : string

This is useful for creating structured identifiers or keys that use a namespace-like prefix separated by a dot, followed by a kebab-case suffix.

Internally, this function uses snake() to normalize the input string into lowercase segments separated by a custom delimiter.

Examples:

  • "serverAskJwtSecret" → "server.ask-jwt-secret"
  • "UserProfilePage" → "user.profile-page"
  • "APIKeyManager" → "api.key-manager"
  • "foo" → "foo"
  • null → ""
Parameters
$source : string|null

The camelCase or PascalCase string to convert.

Tags
example
echo dotKebab("serverAskJwtSecret");
// Output: "server.ask-jwt-secret"

echo dotKebab("UserProfilePage");
// Output: "user.profile-page"

echo dotKebab("APIKeyManager");
// Output: "api.key-manager"

echo dotKebab("foo");
// Output: "foo"

echo dotKebab(null);
// Output: ""
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string

The converted string in dot + kebab-case format.


        
On this page

Search results