You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sanjoy Dey edited this page Oct 31, 2015
·
1 revision
###Introduction
The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without, and underscore to camelCase etc. We mostly access Inflector functions statically as we required functions to be accessible globally.
###Singularize String
echo Inflector::singularize('movies'); // will print movieecho Inflector::singularize('products'); // will print product
###Pluralize String
echo Inflector::pluralize('movie'); // will print moviesecho Inflector::pluralize('product'); // will print products
###Camelize String
Underscore to camelCase String.
echo Inflector::camelize('user_info'); // will print userInfo
###Getting Class Name From Namespace
echo Inflector::getClassName('\Apps\Models\User'); // will print "User"
###DeCamelize String
echo Inflector::camelize('userInfo'); // will print user_info
###Converting String To Table Name
echo Inflector::tabilize('UserInfo'); // Class Name to Table Name. Will print "user_info"
###Classify The String
Will convert underscore or hyphen to class name as below.
echo Inflector::classify('user_info'); // Will print "UserInfo"echo Inflector::classify('user-info'); // Will print "UserInfo"