function testToUnderscores() { $this->assertEquals('under_scores', Inflector::toUnderscores('UnderScores')); $this->assertEquals('under_scores', Inflector::toUnderscores('underScores')); }
/** !Route GET, model/gen/analyzeModelName/$modelName */ public function analyzeModelName($modelName) { Library::import('recess.lang.Inflector'); $this->tableName = Inflector::toPlural(Inflector::toUnderscores($modelName)); $this->isValid = preg_match('/^[a-zA-Z][_a-zA-z0-9]*$/', $modelName) == 1; }
/** * Go from underscores_form or camelCapsForm or ProperCapsForm to English Form. * * @param string $word in underscores_form or camelCapsForm or ProperCapsForm * @return string in English Form */ public static function toEnglish($word) { $word = Inflector::toUnderscores($word); $word = explode('_', $word); $word = array_map('ucfirst', $word); return implode(' ', $word); }