This document is for a version of CakePHP that is no longer supported. Please upgrade to a newer release!

Page Contents

Inflector

The Inflector class takes a string and can manipulate it to handle word variations such as pluralizations or camelizing and is normally accessed statically. Example: Inflector::pluralize('example') returns “examples”.

Class methods

Input

Output

pluralize

Apple, Orange, Person, Man

Apples, Oranges, People, Men

singularize

Apples, Oranges, People, Men

Apple, Orange, Person, Man

camelize

Apple_pie, some_thing, people_person

ApplePie, SomeThing, PeoplePerson

underscore

It should be noted that underscore will only convert camelCase formatted words. Words that contains spaces will be lower-cased, but will not contain an underscore.

applePie, someThing

apple_pie, some_thing

humanize

apple_pie, some_thing, people_person

Apple Pie, Some Thing, People Person

tableize

Apple, UserProfileSetting, Person

apples, user_profile_settings, people

classify

apples, user_profile_settings, people

Apple, UserProfileSetting, Person

variable

apples, user_result, people_people

apples, userResult, peoplePeople

slug

Slug converts special characters into latin versions and converting unmatched characters and spaces to underscores. The slug method expects UTF-8 encoding.

apple purée

apple_puree