/** * Change hyphen name into camel case * @param string $name * @param boolean $hasFirstUppercase Decide if the first character is uppercase. * @return string A CamelCase text. */ public static function fromHyphenToCamelCase($name, $hasFirstUppercase = FALSE) { $words = explode('-', strtolower($name)); if (count($words) == 1) { $hyphenName = Route::fromCamelCaseToUcHyphen($name); $hyphenNameParts = explode("-", $hyphenName); if ($hasFirstUppercase) { $hyphenNameParts[0] = ucfirst($hyphenNameParts[0]); $oneName = join("", $hyphenNameParts); } else { if (false === function_exists('lcfirst')) { $hyphenNameParts[0] = Route::lcFirst($hyphenNameParts[0]); } else { $hyphenNameParts[0] = lcfirst($hyphenNameParts[0]); } $oneName = join("", $hyphenNameParts); } return $oneName; } $camelCaseName = ''; $index = 0; foreach ($words as $word) { if (!$hasFirstUppercase && $index == 0) { $camelCaseName .= trim($word); } else { $camelCaseName .= ucfirst(trim($word)); } $index++; } return $camelCaseName; }