/** * Convert words to PHP Class name * * @param $input * @return string */ public static function className($input) { $output = preg_replace(array('#(?<=[^A-Z\\s])([A-Z\\s])#i'), ' $0', $input); $output = explode(' ', $output); $output = array_map(function ($item) { $item = preg_replace('#[^a-z0-9]#i', '', $item); $item = Filter::ucfirst($item); return $item; }, $output); $output = array_filter($output); return implode('', $output); }
public function testUcfirst() { isSame('Test', Filter::ucfirst('test')); isSame('Test', Filter::ucfirst('Test')); isSame('Test', Filter::ucfirst('TEST')); isSame('Test', Filter::ucfirst('tEST')); }