Inflector Helper

Fournit des méthodes afin de travailler avec la pluralisation et la singularisation des mots ainsi que des méthodes afin de travailler avec les phrases.

Méthodes

uncountable()

uncountable($string) vérifie si le mot fournit est un mot “comptable” ou non. Retourne TRUE ou FALSE. Cette méthode utilise une liste de mot à partir du fichier inflector.php, qui se situe dans le dossier system/config

  • [string] Le mot à verifier
inflector::uncountable('money'); //retourne TRUE
inflector::uncountable('book'); //retourne FALSE

singular()

singular($str, $count = NULL) will attempt to singularize the given string. Returns the string. If a string is uncountable it will return the string without modification.

Note: this function works for English words only.

  • [string] word to singularize
  • [integer] number of things - default NULL
inflector::singular('books'); //returns 'book'
inflector::singular('books',0); //returns 'books'

plural()

plural($str, $count = NULL) will attempt to pluralize the given string. Returns the string. If a string is uncountable it will return the string without modification.

Note: this function works for English words only.

  • [string] word to pluralize
  • [integer] number of things - default NULL
inflector::plural('book'); //returns 'books'
inflector::plural('book',1); //returns 'book'

camelize()

camelize($str) will attempt to camelize the given string. Returns the string.

  • [string] phrase to camelize
inflector::camelize('system_initialization'); //returns 'systemInitialization'
inflector::camelize('system initialization'); //returns 'systemInitialization'

underscore()

underscore($str) makes a phrase underscored instead of spaced. Returns the string.

  • [string] phrase to underscore
inflector::underscore('Underscores a phrase.'); //returns Underscores_a_phrase.'

humanize()

humanize($str) makes a phrase human-readable instead of dashed or underscored. Returns the string.

  • [string] phrase to make human-readable
inflector::humanize('Remove_underscores_from_a_phrase.'); //returns 'Remove underscores from a phrase.'
inflector::humanize('Remove-dashes-from-a-phrase.'); //returns 'Remove dashes from a phrase.'
helpers/inflector.txt · Dernière modification: 23/03/2011 18:17 par voldemort
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0