Source for file normalise.php
Documentation is available at normalise.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Joomla Platform String Normalise Class
* @package Joomla.Platform
* Method to convert a string from camel case.
* This method offers two modes. Grouped allows for splitting on groups of uppercase characters as follows:
* "FooBarABCDef" becomes array("Foo", "Bar", "ABC", "Def")
* "JFooBar" becomes array("J", "Foo", "Bar")
* "J001FooBar002" becomes array("J001", "Foo", "Bar002")
* "abcDef" becomes array("abc", "Def")
* "abc_defGhi_Jkl" becomes array("abc_def", "Ghi_Jkl")
* "ThisIsA_NASAAstronaut" becomes array("This", "Is", "A_NASA", "Astronaut"))
* "JohnFitzgerald_Kennedy" becomes array("John", "Fitzgerald_Kennedy"))
* Non-grouped will split strings at each uppercase character.
* @param string $input The string input (ASCII only).
* @param boolean $grouped Optionally allows splitting on groups of uppercase characters.
* @return string The space separated string.
?
preg_split('/(?<=[^A-Z_])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][^A-Z_])/x', $input)
* Method to convert a string into camel case.
* @param string $input The string input (ASCII only).
* @return string The camel case string.
// Convert words to uppercase and then remove spaces.
$input =
self::toSpaceSeparated($input);
* Method to convert a string into dash separated form.
* @param string $input The string input (ASCII only).
* @return string The dash separated string.
// Convert spaces and underscores to dashes.
* Method to convert a string into space separated form.
* @param string $input The string input (ASCII only).
* @return string The space separated string.
// Convert underscores and dashes to spaces.
* Method to convert a string into underscore separated form.
* @param string $input The string input (ASCII only).
* @return string The underscore separated string.
// Convert spaces and dashes to underscores.
* Method to convert a string into variable form.
* @param string $input The string input (ASCII only).
* @return string The variable string.
// Remove dashes and underscores, then convert to camel case.
$input =
self::toSpaceSeparated($input);
$input =
self::toCamelCase($input);
// Remove leading digits.
// Lowercase the first character.
$first =
substr($input, 0, 1);
// Replace the first character with the lowercase character.
* Method to convert a string into key form.
* @param string $input The string input (ASCII only).
* @return string The key string.
public static function toKey($input)
// Remove spaces and dashes, then convert to lower case.
$input =
self::toUnderscoreSeparated($input);
Documentation generated on Tue, 19 Nov 2013 15:09:35 +0100 by phpDocumentor 1.4.3