Skip to content

Commit

Permalink
Merge pull request #24 from SharkyKZ/toVariable
Browse files Browse the repository at this point in the history
Normalise::toVariable() cleanup
  • Loading branch information
mbabker authored Aug 7, 2019
2 parents 33944ac + 907b191 commit fed0eee
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/Normalise.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,14 @@ public static function toUnderscoreSeparated($input)
*/
public static function toVariable($input)
{
// Remove dashes and underscores, then convert to camel case.
$input = self::toSpaceSeparated($input);
// Convert to camel case.
$input = self::toCamelCase($input);

// Remove leading digits.
$input = preg_replace('#^[0-9]+#', '', $input);

// Lowercase the first character.
$first = substr($input, 0, 1);
$first = strtolower($first);

// Replace the first character with the lowercase character.
$input = substr_replace($input, $first, 0, 1);
$input = lcfirst($input);

return $input;
}
Expand Down

0 comments on commit fed0eee

Please sign in to comment.