Location: PHPKode > projects > PHP on Trax > johnpipi-trax-f599562/trax/doc/__filesource/fsource_PHPonTrax__vendortraxinflector.php.html
<html>
<head>
<title>File Source for inflector.php</title>
<link rel="stylesheet" type="text/css" href="../media/style.css">
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
    <td class="header_top">PHPonTrax</td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td class="header_menu">
  		  [ <a href="../classtrees_PHPonTrax.html" class="menu">class tree: PHPonTrax</a> ]
		  [ <a href="../elementindex_PHPonTrax.html" class="menu">index: PHPonTrax</a> ]
		  [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="200" class="menu">
	<div id="todolist">
			<p><a href="../todolist.html">Todo List</a></p>
	</div>
      <b>Packages:</b><br />
              <a href="../li_PHPonTrax.html">PHPonTrax</a><br />
              <a href="../li_PHPonTraxTest.html">PHPonTraxTest</a><br />
            <br /><br />
                  
                </td>
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<h1 align="center">Source for file inflector.php</h1>
<p>Documentation is available at <a href="../PHPonTrax/_vendor_trax_inflector_php.html">inflector.php</a></p>
<div class="php">
<div class="listing"><pre><ol><li><a name="a1"></a><span class="src-php">&lt;?php</span></li>
<li><a name="a2"></a><span class="src-doc">/**</span></li>
<li><a name="a3"></a><span class="src-doc"> *  File containing the Inflector class</span></li>
<li><a name="a4"></a><span class="src-doc"> *</span></li>
<li><a name="a5"></a><span class="src-doc"> *  (PHP 5)</span></li>
<li><a name="a6"></a><span class="src-doc"> *</span></li>
<li><a name="a7"></a><span class="src-doc"> *  </span><span class="src-doc-coretag">@package</span><span class="src-doc"> PHPonTrax</span></li>
<li><a name="a8"></a><span class="src-doc"> *  </span><span class="src-doc-coretag">@version</span><span class="src-doc"> $Id: inflector.php 195 2006-04-03 22:27:26Z haas $</span></li>
<li><a name="a9"></a><span class="src-doc"> *  </span><span class="src-doc-coretag">@copyright</span><span class="src-doc"> (c) 2005 John Peterson</span></li>
<li><a name="a10"></a><span class="src-doc"> *</span></li>
<li><a name="a11"></a><span class="src-doc"> *   Permission is hereby granted, free of charge, to any person obtaining</span></li>
<li><a name="a12"></a><span class="src-doc"> *   a copy of this software and associated documentation files (the</span></li>
<li><a name="a13"></a><span class="src-doc"> *   &quot;Software&quot;), to deal in the Software without restriction, including</span></li>
<li><a name="a14"></a><span class="src-doc"> *   without limitation the rights to use, copy, modify, merge, publish,</span></li>
<li><a name="a15"></a><span class="src-doc"> *   distribute, sublicense, and/or sell copies of the Software, and to</span></li>
<li><a name="a16"></a><span class="src-doc"> *   permit persons to whom the Software is furnished to do so, subject to</span></li>
<li><a name="a17"></a><span class="src-doc"> *   the following conditions:</span></li>
<li><a name="a18"></a><span class="src-doc"> *</span></li>
<li><a name="a19"></a><span class="src-doc"> *   The above copyright notice and this permission notice shall be</span></li>
<li><a name="a20"></a><span class="src-doc"> *   included in all copies or substantial portions of the Software.</span></li>
<li><a name="a21"></a><span class="src-doc"> *</span></li>
<li><a name="a22"></a><span class="src-doc"> *   THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,</span></li>
<li><a name="a23"></a><span class="src-doc"> *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF</span></li>
<li><a name="a24"></a><span class="src-doc"> *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND</span></li>
<li><a name="a25"></a><span class="src-doc"> *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE</span></li>
<li><a name="a26"></a><span class="src-doc"> *   LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION</span></li>
<li><a name="a27"></a><span class="src-doc"> *   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION</span></li>
<li><a name="a28"></a><span class="src-doc"> *   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</span></li>
<li><a name="a29"></a><span class="src-doc"> */</span></li>
<li><a name="a30"></a>&nbsp;</li>
<li><a name="a31"></a><span class="src-doc">/**</span></li>
<li><a name="a32"></a><span class="src-doc"> *  Implement the Trax naming convention</span></li>
<li><a name="a33"></a><span class="src-doc"> *</span></li>
<li><a name="a34"></a><span class="src-doc"> *  This class provides static methods to implement the</span></li>
<li><a name="a35"></a><span class="src-doc"> *  </span><span class="src-doc-inlinetag">{@tutorial PHPonTrax/naming.pkg Trax naming convention}</span><span class="src-doc">.</span></li>
<li><a name="a36"></a><span class="src-doc"> *  Inflector is never instantiated.</span></li>
<li><a name="a37"></a><span class="src-doc"> *  </span><span class="src-doc-coretag">@tutorial</span><span class="src-doc"> PHPonTrax/Inflector.cls</span></li>
<li><a name="a38"></a><span class="src-doc"> */</span></li>
<li><a name="a39"></a><span class="src-key">class </span><a href="../PHPonTrax/Inflector.html">Inflector</a> <span class="src-sym">{</span></li>
<li><a name="a40"></a>&nbsp;</li>
<li><a name="a41"></a>    <span class="src-doc">/**</span></li>
<li><a name="a42"></a><span class="src-doc">     *  Rules for converting an English singular word to plural form</span></li>
<li><a name="a43"></a><span class="src-doc">     */</span></li>
<li><a name="a44"></a>    <span class="src-key">private </span><span class="src-key">static </span><span class="src-var">$plural_rules </span>=</li>
<li><a name="a45"></a>        <span class="src-key">array</span><span class="src-sym">(  </span><span class="src-str">'/(x|ch|ss|sh)$/' </span>=&gt; <span class="src-str">'\1es'</span><span class="src-sym">,            </span><span class="src-comm"># search, switch, fix, box, process, address</span></li>
<li><a name="a46"></a>                                <span class="src-str">'/series$/' </span>=&gt; <span class="src-str">'\1series'</span><span class="src-sym">,</span></li>
<li><a name="a47"></a>                <span class="src-str">'/([^aeiouy]|qu)ies$/' </span>=&gt; <span class="src-str">'\1y'</span><span class="src-sym">,</span></li>
<li><a name="a48"></a>                <span class="src-str">'/([^aeiouy]|qu)y$/' </span>=&gt; <span class="src-str">'\1ies'</span><span class="src-sym">,        </span><span class="src-comm"># query, ability, agency</span></li>
<li><a name="a49"></a>                                <span class="src-str">'/(?:([^f])fe|([lr])f)$/' </span>=&gt; <span class="src-str">'\1\2ves'</span><span class="src-sym">, </span><span class="src-comm"># half, safe, wife</span></li>
<li><a name="a50"></a>                                <span class="src-str">'/sis$/' </span>=&gt; <span class="src-str">'ses'</span><span class="src-sym">,                      </span><span class="src-comm"># basis, diagnosis</span></li>
<li><a name="a51"></a>                                <span class="src-str">'/([ti])um$/' </span>=&gt; <span class="src-str">'\1a'</span><span class="src-sym">,                 </span><span class="src-comm"># datum, medium</span></li>
<li><a name="a52"></a>                                <span class="src-str">'/person$/' </span>=&gt; <span class="src-str">'people'</span><span class="src-sym">,                </span><span class="src-comm"># person, salesperson</span></li>
<li><a name="a53"></a>                                <span class="src-str">'/man$/' </span>=&gt; <span class="src-str">'men'</span><span class="src-sym">,                      </span><span class="src-comm"># man, woman, spokesman</span></li>
<li><a name="a54"></a>                                <span class="src-str">'/child$/' </span>=&gt; <span class="src-str">'children'</span><span class="src-sym">,               </span><span class="src-comm"># child</span></li>
<li><a name="a55"></a>                                <span class="src-str">'/(.*)status$/' </span>=&gt; <span class="src-str">'\1statuses'</span><span class="src-sym">,</span></li>
<li><a name="a56"></a>                <span class="src-str">'/s$/' </span>=&gt; <span class="src-str">'s'</span><span class="src-sym">,                          </span><span class="src-comm"># no change (compatibility)</span></li>
<li><a name="a57"></a>                                <span class="src-str">'/$/' </span>=&gt; <span class="src-str">'s'</span></li>
<li><a name="a58"></a>        <span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a59"></a>&nbsp;</li>
<li><a name="a60"></a>    <span class="src-doc">/**</span></li>
<li><a name="a61"></a><span class="src-doc">     *  Rules for converting an English plural word to singular form</span></li>
<li><a name="a62"></a><span class="src-doc">     */</span></li>
<li><a name="a63"></a>    <span class="src-key">private </span><span class="src-key">static </span><span class="src-var">$singular_rules </span>=</li>
<li><a name="a64"></a>        <span class="src-key">array</span><span class="src-sym">(  </span><span class="src-str">'/(x|ch|ss)es$/' </span>=&gt; <span class="src-str">'\1'</span><span class="src-sym">,</span></li>
<li><a name="a65"></a>                <span class="src-str">'/movies$/' </span>=&gt; <span class="src-str">'movie'</span><span class="src-sym">,</span></li>
<li><a name="a66"></a>                <span class="src-str">'/series$/' </span>=&gt; <span class="src-str">'series'</span><span class="src-sym">,</span></li>
<li><a name="a67"></a>                <span class="src-str">'/([^aeiouy]|qu)ies$/' </span>=&gt; <span class="src-str">'\1y'</span><span class="src-sym">,</span></li>
<li><a name="a68"></a>                <span class="src-str">'/([lr])ves$/' </span>=&gt; <span class="src-str">'\1f'</span><span class="src-sym">,</span></li>
<li><a name="a69"></a>                <span class="src-str">'/([^f])ves$/' </span>=&gt; <span class="src-str">'\1fe'</span><span class="src-sym">,</span></li>
<li><a name="a70"></a>                <span class="src-str">'/(analy|ba|diagno|parenthe|progno|synop|the)ses$/' </span>=&gt; <span class="src-str">'\1sis'</span><span class="src-sym">,</span></li>
<li><a name="a71"></a>                <span class="src-str">'/([ti])a$/' </span>=&gt; <span class="src-str">'\1um'</span><span class="src-sym">,</span></li>
<li><a name="a72"></a>                <span class="src-str">'/people$/' </span>=&gt; <span class="src-str">'person'</span><span class="src-sym">,</span></li>
<li><a name="a73"></a>                <span class="src-str">'/men$/' </span>=&gt; <span class="src-str">'man'</span><span class="src-sym">,</span></li>
<li><a name="a74"></a>                <span class="src-str">'/(.*)statuses$/' </span>=&gt; <span class="src-str">'\1status'</span><span class="src-sym">,</span></li>
<li><a name="a75"></a>                <span class="src-str">'/children$/' </span>=&gt; <span class="src-str">'child'</span><span class="src-sym">,</span></li>
<li><a name="a76"></a>                <span class="src-str">'/news$/' </span>=&gt; <span class="src-str">'news'</span><span class="src-sym">,</span></li>
<li><a name="a77"></a>                <span class="src-str">'/s$/' </span>=&gt; <span class="src-str">''</span></li>
<li><a name="a78"></a>        <span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a79"></a>&nbsp;</li>
<li><a name="a80"></a>    <span class="src-doc">/**</span></li>
<li><a name="a81"></a><span class="src-doc">     *  Pluralize a word according to English rules</span></li>
<li><a name="a82"></a><span class="src-doc">     *</span></li>
<li><a name="a83"></a><span class="src-doc">     *  Convert a lower-case singular word to plural form.</span></li>
<li><a name="a84"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">string </span><span class="src-doc-var">$word </span><span class="src-doc"> Word to be pluralized</span></li>
<li><a name="a85"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc"> Plural of $word</span></li>
<li><a name="a86"></a><span class="src-doc">     */</span></li>
<li><a name="a87"></a>    <span class="src-key">function </span><a href="../PHPonTrax/Inflector.html#methodpluralize">pluralize</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a88"></a>        <span class="src-var">$original </span>= <span class="src-var">$word</span><span class="src-sym">;</span></li>
<li><a name="a89"></a>        <span class="src-key">foreach</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$plural_rules </span><span class="src-key">as </span><span class="src-var">$rule </span>=&gt; <span class="src-var">$replacement</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a90"></a>            <span class="src-var">$word </span>= <span class="src-id">preg_replace</span><span class="src-sym">(</span><span class="src-var">$rule</span><span class="src-sym">,</span><span class="src-var">$replacement</span><span class="src-sym">,</span><span class="src-var">$word</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a91"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$original </span>!= <span class="src-var">$word</span><span class="src-sym">) </span><span class="src-key">break</span><span class="src-sym">;</span></li>
<li><a name="a92"></a>        <span class="src-sym">}</span></li>
<li><a name="a93"></a>        <span class="src-key">return </span><span class="src-var">$word</span><span class="src-sym">;</span></li>
<li><a name="a94"></a>    <span class="src-sym">}</span></li>
<li><a name="a95"></a>&nbsp;</li>
<li><a name="a96"></a>    <span class="src-doc">/**</span></li>
<li><a name="a97"></a><span class="src-doc">     *  Singularize a word according to English rules</span></li>
<li><a name="a98"></a><span class="src-doc">     *</span></li>
<li><a name="a99"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">string </span><span class="src-doc-var">$word </span><span class="src-doc"> Word to be singularized</span></li>
<li><a name="a100"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc"> Singular of $word</span></li>
<li><a name="a101"></a><span class="src-doc">     */</span></li>
<li><a name="a102"></a>    <span class="src-key">function </span><a href="../PHPonTrax/Inflector.html#methodsingularize">singularize</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a103"></a>        <span class="src-var">$original </span>= <span class="src-var">$word</span><span class="src-sym">;</span></li>
<li><a name="a104"></a>        <span class="src-key">foreach</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-var">$singular_rules </span><span class="src-key">as </span><span class="src-var">$rule </span>=&gt; <span class="src-var">$replacement</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a105"></a>            <span class="src-var">$word </span>= <span class="src-id">preg_replace</span><span class="src-sym">(</span><span class="src-var">$rule</span><span class="src-sym">,</span><span class="src-var">$replacement</span><span class="src-sym">,</span><span class="src-var">$word</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a106"></a>            <span class="src-key">if</span><span class="src-sym">(</span><span class="src-var">$original </span>!= <span class="src-var">$word</span><span class="src-sym">) </span><span class="src-key">break</span><span class="src-sym">;</span></li>
<li><a name="a107"></a>        <span class="src-sym">}</span></li>
<li><a name="a108"></a>        <span class="src-key">return </span><span class="src-var">$word</span><span class="src-sym">;</span></li>
<li><a name="a109"></a>    <span class="src-sym">}</span></li>
<li><a name="a110"></a>&nbsp;</li>
<li><a name="a111"></a>    <span class="src-doc">/**</span></li>
<li><a name="a112"></a><span class="src-doc">     *  Capitalize a word making it all lower case with first letter uppercase</span></li>
<li><a name="a113"></a><span class="src-doc">     *</span></li>
<li><a name="a114"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc"> </span><span class="src-doc-type">string </span><span class="src-doc-var">$word </span><span class="src-doc"> Word to be capitalized</span></li>
<li><a name="a115"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">Capitalized $word</span></li>
<li><a name="a116"></a><span class="src-doc">     */</span></li>
<li><a name="a117"></a>    <span class="src-key">function </span><a href="../PHPonTrax/Inflector.html#methodcapitalize">capitalize</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a118"></a>        <span class="src-key">return </span><a href="http://www.php.net/ucfirst">ucfirst</a><span class="src-sym">(</span><a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$word</span><span class="src-sym">))</span><span class="src-sym">;     </span></li>
<li><a name="a119"></a>    <span class="src-sym">}</span></li>
<li><a name="a120"></a>&nbsp;</li>
<li><a name="a121"></a>    <span class="src-doc">/**</span></li>
<li><a name="a122"></a><span class="src-doc">     *  Convert a phrase from the lower case and underscored form</span></li>
<li><a name="a123"></a><span class="src-doc">     *  to the camel case form</span></li>
<li><a name="a124"></a><span class="src-doc">     *</span></li>
<li><a name="a125"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$lower_case_and_underscored_word </span><span class="src-doc"> Phrase to</span></li>
<li><a name="a126"></a><span class="src-doc">     *                                                   convert</span></li>
<li><a name="a127"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc"> Camel case form of the phrase</span></li>
<li><a name="a128"></a><span class="src-doc">     */</span></li>
<li><a name="a129"></a>    <span class="src-key">function </span><a href="../PHPonTrax/Inflector.html#methodcamelize">camelize</a><span class="src-sym">(</span><span class="src-var">$lower_case_and_underscored_word</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a130"></a>        <span class="src-key">return </span><a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot; &quot;</span><span class="src-sym">,</span><span class="src-str">&quot;&quot;</span><span class="src-sym">,</span><a href="http://www.php.net/ucwords">ucwords</a><span class="src-sym">(</span><a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;_&quot;</span><span class="src-sym">,</span><span class="src-str">&quot; &quot;</span><span class="src-sym">,</span><span class="src-var">$lower_case_and_underscored_word</span><span class="src-sym">)))</span><span class="src-sym">;</span></li>
<li><a name="a131"></a>    <span class="src-sym">}</span></li>
<li><a name="a132"></a>&nbsp;</li>
<li><a name="a133"></a>    <span class="src-doc">/**</span></li>
<li><a name="a134"></a><span class="src-doc">     *  Convert a phrase from the camel case form to the lower case</span></li>
<li><a name="a135"></a><span class="src-doc">     *  and underscored form</span></li>
<li><a name="a136"></a><span class="src-doc">     *</span></li>
<li><a name="a137"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$camel_cased_word </span><span class="src-doc"> Phrase to convert</span></li>
<li><a name="a138"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">Lower case and underscored form of the phrase</span></li>
<li><a name="a139"></a><span class="src-doc">     */</span></li>
<li><a name="a140"></a>    <span class="src-key">function </span><a href="../PHPonTrax/Inflector.html#methodunderscore">underscore</a><span class="src-sym">(</span><span class="src-var">$camel_cased_word</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a141"></a>        <span class="src-var">$camel_cased_word </span>= <a href="http://www.php.net/preg_replace">preg_replace</a><span class="src-sym">(</span><span class="src-str">'/([A-Z]+)([A-Z])/'</span><span class="src-sym">,</span><span class="src-str">'\1_\2'</span><span class="src-sym">,</span><span class="src-var">$camel_cased_word</span><span class="src-sym">)</span><span class="src-sym">;</span></li>
<li><a name="a142"></a>        <span class="src-key">return </span><a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><a href="http://www.php.net/preg_replace">preg_replace</a><span class="src-sym">(</span><span class="src-str">'/([a-z])([A-Z])/'</span><span class="src-sym">,</span><span class="src-str">'\1_\2'</span><span class="src-sym">,</span><span class="src-var">$camel_cased_word</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a143"></a>    <span class="src-sym">}</span></li>
<li><a name="a144"></a>&nbsp;</li>
<li><a name="a145"></a>    <span class="src-doc">/**</span></li>
<li><a name="a146"></a><span class="src-doc">     *  Generate a more human version of a lower case underscored word</span></li>
<li><a name="a147"></a><span class="src-doc">     *</span></li>
<li><a name="a148"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$lower_case_and_underscored_word </span><span class="src-doc"> A word or phrase in</span></li>
<li><a name="a149"></a><span class="src-doc">     *                                            lower_case_underscore form</span></li>
<li><a name="a150"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">The input value with underscores replaced by</span></li>
<li><a name="a151"></a><span class="src-doc">     *   blanks and the first letter of each word capitalized</span></li>
<li><a name="a152"></a><span class="src-doc">     */</span></li>
<li><a name="a153"></a>    <span class="src-key">function </span><a href="../PHPonTrax/Inflector.html#methodhumanize">humanize</a><span class="src-sym">(</span><span class="src-var">$lower_case_and_underscored_word</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a154"></a>        <span class="src-key">return </span><a href="http://www.php.net/ucwords">ucwords</a><span class="src-sym">(</span><a href="http://www.php.net/str_replace">str_replace</a><span class="src-sym">(</span><span class="src-str">&quot;_&quot;</span><span class="src-sym">,</span><span class="src-str">&quot; &quot;</span><span class="src-sym">,</span><span class="src-var">$lower_case_and_underscored_word</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a155"></a>    <span class="src-sym">}</span></li>
<li><a name="a156"></a>&nbsp;</li>
<li><a name="a157"></a>    <span class="src-doc">/**</span></li>
<li><a name="a158"></a><span class="src-doc">     *  Convert a class name to the corresponding table name</span></li>
<li><a name="a159"></a><span class="src-doc">     *</span></li>
<li><a name="a160"></a><span class="src-doc">     *  The class name is a singular word or phrase in CamelCase.</span></li>
<li><a name="a161"></a><span class="src-doc">     *  By convention it corresponds to a table whose name is a plural</span></li>
<li><a name="a162"></a><span class="src-doc">     *  word or phrase in lower case underscore form.</span></li>
<li><a name="a163"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$class_name </span><span class="src-doc"> Name of </span><span class="src-doc-inlinetag">{@link ActiveRecord}</span><span class="src-doc"> sub-class</span></li>
<li><a name="a164"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">Pluralized lower_case_underscore form of name</span></li>
<li><a name="a165"></a><span class="src-doc">     */</span></li>
<li><a name="a166"></a>    <span class="src-key">function </span><a href="../PHPonTrax/Inflector.html#methodtableize">tableize</a><span class="src-sym">(</span><span class="src-var">$class_name</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a167"></a>        <span class="src-key">return </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">pluralize</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">underscore</span><span class="src-sym">(</span><span class="src-var">$class_name</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a168"></a>    <span class="src-sym">}</span></li>
<li><a name="a169"></a>&nbsp;</li>
<li><a name="a170"></a>    <span class="src-doc">/**</span></li>
<li><a name="a171"></a><span class="src-doc">     *  Convert a table name to the corresponding class name</span></li>
<li><a name="a172"></a><span class="src-doc">     *</span></li>
<li><a name="a173"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$table_name </span><span class="src-doc">Name of table in the database</span></li>
<li><a name="a174"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">Singular CamelCase form of $table_name</span></li>
<li><a name="a175"></a><span class="src-doc">     */</span></li>
<li><a name="a176"></a>    <span class="src-key">function </span><a href="../PHPonTrax/Inflector.html#methodclassify">classify</a><span class="src-sym">(</span><span class="src-var">$table_name</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a177"></a>        <span class="src-key">return </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">camelize</span><span class="src-sym">(</span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">singularize</span><span class="src-sym">(</span><span class="src-var">$table_name</span><span class="src-sym">))</span><span class="src-sym">;</span></li>
<li><a name="a178"></a>    <span class="src-sym">}</span></li>
<li><a name="a179"></a>&nbsp;</li>
<li><a name="a180"></a>    <span class="src-doc">/**</span></li>
<li><a name="a181"></a><span class="src-doc">     *  Get foreign key column corresponding to a table name</span></li>
<li><a name="a182"></a><span class="src-doc">     *</span></li>
<li><a name="a183"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@param </span><span class="src-doc-type">string </span><span class="src-doc-var">$table_name </span><span class="src-doc">Name of table referenced by foreign</span></li>
<li><a name="a184"></a><span class="src-doc">     *     key</span></li>
<li><a name="a185"></a><span class="src-doc">     *  </span><span class="src-doc-coretag">@return </span><span class="src-doc-type">string </span><span class="src-doc">Column name of the foreign key column</span></li>
<li><a name="a186"></a><span class="src-doc">     */</span></li>
<li><a name="a187"></a>    <span class="src-key">function </span><a href="../PHPonTrax/Inflector.html#methodforeign_key">foreign_key</a><span class="src-sym">(</span><span class="src-var">$class_name</span><span class="src-sym">) </span><span class="src-sym">{</span></li>
<li><a name="a188"></a>        <span class="src-key">return </span><span class="src-id">self</span><span class="src-sym">::</span><span class="src-id">underscore</span><span class="src-sym">(</span><span class="src-var">$class_name</span><span class="src-sym">) </span>. <span class="src-str">&quot;_id&quot;</span><span class="src-sym">;</span></li>
<li><a name="a189"></a>    <span class="src-sym">}</span></li>
<li><a name="a190"></a>    </li>
<li><a name="a191"></a><span class="src-sym">}</span></li>
<li><a name="a192"></a>&nbsp;</li>
<li><a name="a193"></a>&nbsp;</li>
<li><a name="a194"></a><span class="src-php">?&gt;</span></li>
</ol></pre></div>
</div>
        <div class="credit">
		    <hr />
		    Documentation generated on Thu, 04 May 2006 19:47:46 -0600 by <a href="http://www.phpdoc.org">phpDocumentor 1.3.0RC4</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>
Return current item: PHP on Trax