Welcome, Guest Log In

Class Krai_Lib_Inflector

Class Overview

Inflector class - changes case conventions and plurality

This class provides functionality to convert words from singluar to plural and vice versa. Additionally, it can change things from CamelCase to lowercase_with_underscores.

Located in /Krai/Lib/Inflector.php [line 23]



		
		
		
		

Properties

Methods

[ Top ]
Property Summary
array   $_irregular   Holds irregular pluralizations
array   $_plural   Holds pluralizations
array   $_singular   Holds singular-izations
array   $_uncountable   List of nouns which are not pluralizable

[ Top ]
Method Summary
Krai_Lib_Inflector   __construct()   Constructor - doesn't do anything
string   Camel2Underscore()   Changes a string from CamelCase to underscore_case
string   Pluralize()   Changes a noun from singular to plural
string   Singular()   Changes a word from plural to singular
string   Underscore2Camel()   Changes a string from underscore_case to CamelCase

[ Top ]
Properties
array   $_irregular = array(
'person' => 'people',
'man' => 'men',
'child' => 'children',
'sex' => 'sexes',
'move' => 'moves'
)
[line 104]

Holds irregular pluralizations

This is an array of irregular pluralizations

API Tags:
Access:  private


[ Top ]
array   $_plural = array(
'/(quiz)$/i' => '$1zes',
'/^(ox)$/i' => '$1en',
'/([m|l])ouse$/i' => '$1ice',
'/(matr|vert|ind)ix|ex$/i' => '$1ices',
'/(x|ch|ss|sh)$/i' => '$1es',
'/([^aeiouy]|qu)ies$/i' => '$1y',
'/([^aeiouy]|qu)y$/i' => '$1ies',
'/(hive)$/i' => '$1s',
'/(?:([^f])fe|([lr])f)$/i' => '$1$2ves',
'/sis$/i' => 'ses',
'/([ti])um$/i' => '$1a',
'/(buffal|tomat)o$/i' => '$1oes',
'/(bu)s$/i' => '$1ses',
'/(alias|status)/i'=> '$1es',
'/(octop|vir)us$/i'=> '$1i',
'/(ax|test)is$/i'=> '$1es',
'/s$/i'=> 's',
'/$/'=> 's'
)
[line 33]

Holds pluralizations

This is an array of pluralization regular expression patterns and replacements

API Tags:
Access:  private


[ Top ]
array   $_singular = array (
'/(quiz)zes$/i' => '\\1',
'/(matr)ices$/i' => '\\1ix',
'/(vert|ind)ices$/i' => '\\1ex',
'/^(ox)en/i' => '\\1',
'/(alias|status)es$/i' => '\\1',
'/([octop|vir])i$/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])a$/i' => '\\1um',
'/(n)ews$/i' => '\\1ews',
'/s$/i' => '',
)
[line 61]

Holds singular-izations

This is an array of singularization regular expression patterns and replacements

API Tags:
Access:  private


[ Top ]
array   $_uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep') [line 95]

List of nouns which are not pluralizable

This is an array of some nouns which do not change from singular to plural

API Tags:
Access:  private


[ Top ]
Methods
Constructor __construct  [line 118]

  Krai_Lib_Inflector __construct( )

Constructor - doesn't do anything

This doesn't do anything except create a new instance.


API Tags:
Access:  public


[ Top ]
Camel2Underscore  [line 131]

  string Camel2Underscore( string $str  )

Changes a string from CamelCase to underscore_case

This function takes a string and replaces capital letters by lowercase letters preceded by underscores (except the first letter of the new string will never) be an underscore unless the first letter of the original was).

Parameters:
string   $str: 

API Tags:
Access:  public


[ Top ]
Pluralize  [line 162]

  string Pluralize( string $word  )

Changes a noun from singular to plural

This function takes a word and attempts to make it plural. It returns false if it cannot figure out how.

Parameters:
string   $word: 

API Tags:
Access:  public


[ Top ]
Singular  [line 200]

  string Singular( string $word  )

Changes a word from plural to singular

This function takes a word and attempts to singularize it. It returns false if it cannot figure out how.

Parameters:
string   $word: 

API Tags:
Access:  public


[ Top ]
Underscore2Camel  [line 147]

  string Underscore2Camel( string $str  )

Changes a string from underscore_case to CamelCase

This function takes a string and capitalizes the first letter and any letter preceded by an underscore character. It also capitalizes the first letter of the string.

Parameters:
string   $str: 

API Tags:
Access:  public


[ Top ]

Documentation generated on Fri, 25 Jul 2008 15:19:21 -0400 by phpDocumentor 1.4.2
Krai Framework site admin credits sitemap valid xhtml?