summaryrefslogtreecommitdiff
path: root/src/application/mystic/forum/utils/StringUtils.php
diff options
context:
space:
mode:
authorJonas Kohl <git@jonaskohl.de>2024-09-08 17:53:55 +0200
committerJonas Kohl <git@jonaskohl.de>2024-09-08 17:53:55 +0200
commit415a0a96a76afbe7f1ad2f51862641793caf1b6c (patch)
tree1168316bff6a2ec04ee27db5ada5431ba6631ce4 /src/application/mystic/forum/utils/StringUtils.php
Initial commit
Diffstat (limited to 'src/application/mystic/forum/utils/StringUtils.php')
-rw-r--r--src/application/mystic/forum/utils/StringUtils.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/application/mystic/forum/utils/StringUtils.php b/src/application/mystic/forum/utils/StringUtils.php
new file mode 100644
index 0000000..7d4bf9d
--- /dev/null
+++ b/src/application/mystic/forum/utils/StringUtils.php
@@ -0,0 +1,24 @@
+<?php
+declare(strict_types=1);
+
+namespace mystic\forum\utils;
+
+final class StringUtils {
+ use StaticClass;
+
+ public static function camelToSnake(string $camelCase): string {
+ $result = '';
+
+ for ($i = 0; $i < strlen($camelCase); $i++) {
+ $char = $camelCase[$i];
+
+ if (ctype_upper($char)) {
+ $result .= '_' . strtolower($char);
+ } else {
+ $result .= $char;
+ }
+ }
+
+ return ltrim($result, '_');
+ }
+}