Skip to content

Commit

Permalink
Added PascalCase method
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk authored Mar 8, 2024
1 parent f4c47c0 commit 3adb393
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,30 @@ public static function className(object|string $class): string
}


/**
* @example snake_case
*/
public static function snakeCase(string $value): string
{
return strtolower(preg_replace('/[A-Z]/', '_$0', $value));
}


/**
* @example camelCase
*/
public static function camelCase(string $value): string
{
return lcfirst(implode('', array_map('ucfirst', preg_split('/[_-]/', $value))));
return lcfirst(static::pascalCase($value));
}


/**
* @example PascalCase
*/
public static function pascalCase(string $value): string
{
return implode('', array_map('ucfirst', preg_split('/[_-]/', $value)));
}


Expand Down

0 comments on commit 3adb393

Please sign in to comment.