Class Inflector

Description

Inflector for pluralize and singularize English nouns.

Inflector for pluralize and singularize English nouns. This Inflector is a port of Ruby on Rails Inflector. It can be really helpful for developers that want to create frameworks based on naming conventions rather than configurations. It was ported to PHP for the Akelos Framework, a multilingual Ruby on Rails like framework for PHP that will be launched soon.

  • author: Bermi Ferrer Martinez <akelos com bermi akelos com>
  • version: $Revision 0.1 $
  • copyright: Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
  • since: 0.1
  • license: GNU

Located in /application/libraries/Inflector.php (line 38)


	
			
Method Summary
 static string camelize (string $word)
 static string classify (string $table_name)
 static string humanize (string $word, [string $uppercase = ''])
 static string ordinalize (integer $number)
 static string pluralize (string $word)
 static string singularize (string $word)
 static string tableize (string $class_name)
 static string titleize (string $word, [string $uppercase = ''])
 static string underscore (string $word)
 static string variablize (string $word)
Methods
static camelize (line 222)

Returns given word as CamelCased

Returns given word as CamelCased Converts a word like "send_email" to "SendEmail". It will remove non alphanumeric character from the word, so "who's online" will be converted to "WhoSOnline"

string camelize (string $word)
  • string $word: Word to convert to camel case
static classify (line 333)

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

Converts a table name to its class name according to rails naming conventions. Converts "people" to "Person"

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

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.

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. If you need to uppercase all the words you just have to pass 'all' as a second parameter.

  • return: Human-readable word
  • access: public
string humanize (string $word, [string $uppercase = ''])
  • string $word: String to "humanize"
  • string $uppercase: If set to 'all' it will uppercase all the words instead of just the first one.
static ordinalize (line 351)

Converts number to its ordinal English form.

Converts number to its ordinal English form. This method converts 13 to 13th, 2 to 2nd ...

  • return: Ordinal representation of given string.
  • access: public
string ordinalize (integer $number)
  • integer $number: Number to get its ordinal value
static pluralize (line 54)

Pluralizes English nouns.

Pluralizes English nouns.

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

Singularizes English nouns.

Singularizes English nouns.

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

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

Converts a class name to its table name according to rails naming conventions. Converts "Person" to "people"

string tableize (string $class_name)
  • string $class_name: Class name for getting related table_name.
static titleize (line 200)

Converts an underscored or CamelCase word into a English sentence.

Converts an underscored or CamelCase word into a English sentence. The titleize function converts text like "WelcomePage", "welcome_page" or "welcome page" to this "Welcome Page". If second parameter is set to 'first' it will only capitalize the first character of the title.

  • return: Text formatted as title
  • access: public
string titleize (string $word, [string $uppercase = ''])
  • string $word: Word to format as tile
  • string $uppercase: If set to 'first' it will only uppercase the first character. Otherwise it will uppercase all the words in the title.
static underscore (line 243)

Converts a word "into_it_s_underscored_version" Convert any "CamelCased" or "ordinary Word" into an "underscored_word".

Converts a word "into_it_s_underscored_version" Convert any "CamelCased" or "ordinary Word" into an "underscored_word". This can be really useful for creating friendly URLs.

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

Same as camelize but first char is underscored

Same as camelize but first char is underscored Converts a word like "send_email" to "sendEmail". It will remove non alphanumeric character from the word, so "who's online" will be converted to "whoSOnline"

string variablize (string $word)
  • string $word: Word to lowerCamelCase

Documentation generated on Fri, 05 Jun 2009 13:57:45 -0400 by phpDocumentor 1.4.2