Skip to content

Commit

Permalink
Cleaning up formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jperras committed Apr 10, 2009
1 parent 67fffaa commit d72dad5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cake/libs/inflector.php
Expand Up @@ -43,6 +43,7 @@
* @link http://book.cakephp.org/view/491/Inflector
*/
class Inflector extends Object {

/**
* Plural inflector rules
*
Expand Down Expand Up @@ -109,6 +110,7 @@ class Inflector extends Object {
'turf' => 'turfs'
)
);

/**
* Singular inflector rules
*
Expand Down Expand Up @@ -156,6 +158,7 @@ class Inflector extends Object {
),
'irregular' => array()
);

/**
* Words that should not be inflected
*
Expand All @@ -177,21 +180,22 @@ class Inflector extends Object {
'Yengeese'
);


/**
* Cached array identity map of pluralized words.
*
* @var array
* @access protected
**/
var $_pluralized = array();

/**
* Cached array identity map of singularized words.
*
* @var array
* @access protected
**/
var $_singularized = array();

/**
* Gets a reference to the Inflector object instance
*
Expand All @@ -206,6 +210,7 @@ function &getInstance() {
}
return $instance[0];
}

/**
* Adds custom inflection $rules, of either 'plural' or 'singular' $type.
*
Expand Down Expand Up @@ -234,6 +239,7 @@ function rules($type, $rules = array()) {
$_this->{$type}['rules'] = array_merge($rules, $_this->{$type}['rules']);

}

/**
* Return $word in plural form.
*
Expand Down Expand Up @@ -329,6 +335,7 @@ function singularize($word) {
$_this->_singularized[$word] = $word;
return $word;
}

/**
* Returns the given lower_case_and_underscored_word as a CamelCased word.
*
Expand All @@ -341,6 +348,7 @@ function singularize($word) {
function camelize($lowerCaseAndUnderscoredWord) {
return str_replace(" ", "", ucwords(str_replace("_", " ", $lowerCaseAndUnderscoredWord)));
}

/**
* Returns the given camelCasedWord as an underscored_word.
*
Expand All @@ -353,6 +361,7 @@ function camelize($lowerCaseAndUnderscoredWord) {
function underscore($camelCasedWord) {
return strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord));
}

/**
* Returns the given underscored_word_group as a Human Readable Word Group.
* (Underscores are replaced by spaces and capitalized following words.)
Expand All @@ -366,6 +375,7 @@ function underscore($camelCasedWord) {
function humanize($lowerCaseAndUnderscoredWord) {
return ucwords(str_replace("_", " ", $lowerCaseAndUnderscoredWord));
}

/**
* Returns corresponding table name for given model $className. ("people" for the model class "Person").
*
Expand All @@ -378,6 +388,7 @@ function humanize($lowerCaseAndUnderscoredWord) {
function tableize($className) {
return Inflector::pluralize(Inflector::underscore($className));
}

/**
* Returns Cake model class name ("Person" for the database table "people".) for given database table.
*
Expand All @@ -390,6 +401,7 @@ function tableize($className) {
function classify($tableName) {
return Inflector::camelize(Inflector::singularize($tableName));
}

/**
* Returns camelBacked version of an underscored string.
*
Expand All @@ -404,6 +416,7 @@ function variable($string) {
$replace = strtolower(substr($string, 0, 1));
return preg_replace('/\\w/', $replace, $string, 1);
}

/**
* Returns a string with all spaces converted to underscores (by default), accented
* characters converted to non-accented characters, and non word characters removed.
Expand Down

0 comments on commit d72dad5

Please sign in to comment.