Class FOFInflector

Description

FOFInflector to pluralize and singularize English nouns.

  • since: 1.0

Located in /libraries/fof/inflector/inflector.php (line 21)


	
			
Variable Summary
 static array $_cache
 static array $_rules
Method Summary
 static void addWord (string $singular, string $plural)
 static string camelize (string $word)
 static string classify (string $tableName)
 static array explode (string $word)
 static string getPart (string $string, integer $index, [string $default = null])
 static string humanize (string $word)
 static string implode (array $words)
 static boolean isPlural (string $string)
 static boolean isSingular (string $string)
 static string pluralize (string $word)
 static string singularize (string $word)
 static string tableize (string $className)
 static string underscore (string $word)
 static string variablize (string $string)
Variables
static array $_cache = array(
'singularized' => array(),'pluralized'=>array())
(line 118)

Cache of pluralized and singularized nouns.

  • access: protected
static array $_rules = array
(
'pluralization' => array(
'/move$/i' => 'moves',
'/sex$/i' => 'sexes',
'/child$/i' => 'children',
'/man$/i' => 'men',
'/foot$/i' => 'feet',
'/person$/i' => 'people',
'/taxon$/i' => 'taxa',
'/(quiz)$/i' => '$1zes',
'/^(ox)$/i' => '$1en',
'/(m|l)ouse$/i' => '$1ice',
'/(matr|vert|ind|suff)ix|ex$/i' => '$1ices',
'/(x|ch|ss|sh)$/i' => '$1es',
'/([^aeiouy]|qu)y$/i' => '$1ies',
'/(?:([^f])fe|([lr])f)$/i' => '$1$2ves',
'/sis$/i' => 'ses',
'/([ti]|addend)um$/i' => '$1a',
'/(alumn|formul)a$/i' => '$1ae',
'/(buffal|tomat|her)o$/i' => '$1oes',
'/(bu)s$/i' => '$1ses',
'/(alias|status)$/i' => '$1es',
'/(octop|vir)us$/i' => '$1i',
'/(gen)us$/i' => '$1era',
'/(ax|test)is$/i' => '$1es',
'/s$/i' => 's',
'/$/' => 's',
),'singularization'=>array('/cookies$/i'=>'cookie','/moves$/i'=>'move','/sexes$/i'=>'sex','/children$/i'=>'child','/men$/i'=>'man','/feet$/i'=>'foot','/people$/i'=>'person','/taxa$/i'=>'taxon','/databases$/i'=>'database','/(quiz)zes$/i'=>'\1','/(matr|suff)ices$/i'=>'\1ix','/(vert|ind)ices$/i'=>'\1ex','/^(ox)en/i'=>'\1','/(alias|status)es$/i'=>'\1','/(tomato|hero|buffalo)es$/i'=>'\1','/([octop|vir])i$/i'=>'\1us','/(gen)era$/i'=>'\1us','/(cris|^ax|test)es$/i'=>'\1is','/(shoe)s$/i'=>'\1','/(o)es$/i'=>'\1','/(bus)es$/i'=>'\1','/([m|l])ice$/i'=>'\1ouse','/(x|ch|ss|sh)es$/i'=>'\1','/(m)ovies$/i'=>'\1ovie','/(s)eries$/i'=>'\1eries','/([^aeiouy]|qu)ies$/i'=>'\1y','/([lr])ves$/i'=>'\1f','/(tive)s$/i'=>'\1','/(hive)s$/i'=>'\1','/([^f])ves$/i'=>'\1fe','/(^analy)ses$/i'=>'\1sis','/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i'=>'\1\2sis','/([ti]|addend)a$/i'=>'\1um','/(alumn|formul)ae$/i'=>'$1a','/(n)ews$/i'=>'\1ews','/(.*)ss$/i'=>'\1ss','/(.*)s$/i'=>'\1',),'countable'=>array('aircraft','cannon','deer','equipment','fish','information','money','moose','rice','series','sheep','species','swine',))
(line 28)

Rules for pluralizing and singularizing of nouns.

  • access: protected
Methods
static addWord (line 140)

Add a word to the cache, useful to make exceptions or to add words in other languages.

  • access: public
static void addWord (string $singular, string $plural)
  • string $singular: word.
  • string $plural: word.
static camelize (line 235)

Returns given word as CamelCased.

Converts a word like "foo_bar" or "foo bar" to "FooBar". It will remove non alphanumeric characters from the word, so "who's online" will be converted to "WhoSOnline"

  • return: UpperCamelCasedWord
  • access: public
static string camelize (string $word)
  • string $word: Word to convert to camel case.
static classify (line 343)

Converts a table name to its class name according to Koowa naming conventions.

static string classify (string $tableName)
  • string $tableName: Table name for getting related ClassName.
static explode (line 270)

Convert any "CamelCased" word into an array of strings

Returns an array of strings each of which is a substring of string formed by splitting it at the camelcased letters.

  • return: Array of strings
  • access: public
static array explode (string $word)
  • string $word: Word to explode
static getPart (line 424)

Gets a part of a CamelCased word by index.

Use a negative index to start at the last part of the word (-1 is the last part)

  • access: public
static string getPart (string $string, integer $index, [string $default = null])
  • string $string: Word
  • integer $index: Index of the part
  • string $default: Default value
static humanize (line 302)

Returns a human-readable string from $word.

Returns a human-readable string from $word, by replacing underscores with a space, and by upper-casing the initial character by default.

  • return: Human-readable word
  • access: public
static string humanize (string $word)
  • string $word: String to "humanize"
static implode (line 284)

Convert an array of strings into a "CamelCased" word.

  • return: UpperCamelCasedWord
  • access: public
static string implode (array $words)
  • array $words: Array to implode
static isPlural (line 397)

Check to see if an Enlish word is plural.

  • access: public
static boolean isPlural (string $string)
  • string $string: String to be checked.
static isSingular (line 375)

Check to see if an English word is singular

  • access: public
static boolean isSingular (string $string)
  • string $string: The word to check
static pluralize (line 153)

Singular English word to plural.

  • return: Plural noun.
  • access: public
static string pluralize (string $word)
  • string $word: word to pluralize.
static singularize (line 192)

Plural English word to singular.

  • return: Singular noun.
  • access: public
static string singularize (string $word)
  • string $word: Word to singularize.
static tableize (line 321)

Converts a class name to its table name according to Koowa naming conventions.

Converts "Person" to "people"

static string tableize (string $className)
  • string $className: Class name for getting related table_name.
static underscore (line 252)

Converts a word "into_it_s_underscored_version"

Convert any "CamelCased" or "ordinary Word" into an "underscored_word".

  • return: Underscored word
  • access: public
static string underscore (string $word)
  • string $word: Word to underscore
static variablize (line 359)

Returns camelBacked version of a string. Same as camelize but first char is lowercased.

static string variablize (string $string)
  • string $string: String to be camelBacked.

Documentation generated on Tue, 19 Nov 2013 15:05:33 +0100 by phpDocumentor 1.4.3