function underscore($string) { return Inflector::underscore($string); }
/** * Generate a foreign key column name by inflecting a class name. * * @param string $class * @return string */ public function buildForeignKey($class) { if (strpos($class, '\\') !== false) { $class = Path::className($class); } return Inflector::underscore($class) . '_id'; }
/** * Method to apply custom dispatchers to specific container or controller scopes. * * @access public * @param Closure $Dispatcher * @param array $scope * @return void * @static */ public static function setup(Closure $Dispatcher, array $scope = array()) { $scope = $scope + array('container' => '*', 'controller' => '*'); if ($scope['container'] != '*') { $scope['container'] = Inflector::underscore($scope['container']); } if ($scope['controller'] != '*') { $scope['controller'] = Inflector::underscore($scope['controller']); } self::$__mapping[$scope['container'] . '.' . $scope['controller']] = $Dispatcher; }
/** * Test that strings are returned as underscored slugs. */ public function testUnderscore() { $this->assertEquals('camel_case', Inflector::underscore('camel Case')); $this->assertEquals('stu_dly_ca_se', Inflector::underscore('StuDly CaSe')); $this->assertEquals('title_case', Inflector::underscore('Title Case')); $this->assertEquals('normal_case', Inflector::underscore('Normal case')); $this->assertEquals('lowercase', Inflector::underscore('lowercase')); $this->assertEquals('u_p_p_e_r_c_a_s_e', Inflector::underscore('UPPERCASE')); $this->assertEquals('under_score', Inflector::underscore('under_score')); $this->assertEquals('dashes', Inflector::underscore('dash-es')); $this->assertEquals('123_numbers', Inflector::underscore('123 numbers')); $this->assertEquals('with_e_x_txml', Inflector::underscore('with EXT.xml')); $this->assertEquals('lots_of_white_space', Inflector::underscore('lots of white space')); }