File modules/util/text/Converter.class.php

Last commit: Wed Feb 10 22:04:26 2021 +0100	Jan Dankert	Provide the theme configuration through a class.
1 <?php 2 3 4 namespace util\text; 5 6 7 class Converter 8 { 9 public static function toCamelCase($string) { 10 $string = str_replace('-', ' ', $string); 11 $string = str_replace('_', ' ', $string); 12 $string = ucwords(strtolower($string)); 13 $string = str_replace(' ', '', $string); 14 $string = lcfirst($string); 15 16 return $string; 17 } 18 19 20 public static function camelToUnderscore($string, $us = "-") { 21 22 return strtolower(preg_replace( 23 '/(?<=\d)(?=[A-Za-z])|(?<=[A-Za-z])(?=\d)|(?<=[a-z])(?=[A-Z])/', $us, $string)); 24 } 25 }
Download modules/util/text/Converter.class.php
History Wed, 10 Feb 2021 22:04:26 +0100 Jan Dankert Provide the theme configuration through a class.