/** * Get the human attribute name for a given attribute * * @return string */ public function humanAttributeName($attr) { $col = $this->columnForAttribute($attr); return Mad_Support_Inflector::humanize($col->getName()); }
public function testHumanize() { // most common scenarios (column name => human) $this->assertEquals('Derek', Mad_Support_Inflector::humanize('derek')); $this->assertEquals('Dereks test', Mad_Support_Inflector::humanize('dereks_test')); $this->assertEquals('Dereks test', Mad_Support_Inflector::humanize('dereks_test_id')); // not as common (columns are usually underscored) $this->assertEquals('Derek', Mad_Support_Inflector::humanize('Derek')); $this->assertEquals('Dereks', Mad_Support_Inflector::humanize('Dereks')); $this->assertEquals('Dereks test', Mad_Support_Inflector::humanize('dereksTest')); $this->assertEquals('Dereks test', Mad_Support_Inflector::humanize('dereksTestId')); $this->assertEquals('Dereks test', Mad_Support_Inflector::humanize('DereksTest')); $this->assertEquals('Dereks test', Mad_Support_Inflector::humanize('Dereks_Test')); }