From 3adb3938ed7b833be9352e66bcd1744f15036147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Proch=C3=A1zka?= Date: Fri, 8 Mar 2024 15:01:27 +0100 Subject: [PATCH] Added PascalCase method --- src/Format.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Format.php b/src/Format.php index c937d1a..048ed35 100644 --- a/src/Format.php +++ b/src/Format.php @@ -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))); }